module Ledger.Types
where
import Ledger.Utils
import qualified Data.Map as Map
import System.Time (ClockTime)
import Data.Typeable (Typeable)
type SmartDate = (String,String,String)
data WhichDate = ActualDate | EffectiveDate deriving (Eq,Show)
data DateSpan = DateSpan (Maybe Day) (Maybe Day) deriving (Eq,Show,Ord)
data Interval = NoInterval | Daily | Weekly | Monthly | Quarterly | Yearly
deriving (Eq,Show,Ord)
type AccountName = String
data Side = L | R deriving (Eq,Show,Ord)
data Commodity = Commodity {
symbol :: String,
side :: Side,
spaced :: Bool,
comma :: Bool,
precision :: Int
} deriving (Eq,Show,Ord)
data Amount = Amount {
commodity :: Commodity,
quantity :: Double,
price :: Maybe MixedAmount
} deriving (Eq)
newtype MixedAmount = Mixed [Amount] deriving (Eq)
data PostingType = RegularPosting | VirtualPosting | BalancedVirtualPosting
deriving (Eq,Show)
data Posting = Posting {
pstatus :: Bool,
paccount :: AccountName,
pamount :: MixedAmount,
pcomment :: String,
ptype :: PostingType,
ptransaction :: Maybe Transaction
} deriving (Eq)
data Transaction = Transaction {
tdate :: Day,
teffectivedate :: Maybe Day,
tstatus :: Bool,
tcode :: String,
tdescription :: String,
tcomment :: String,
tpostings :: [Posting],
tpreceding_comment_lines :: String
} deriving (Eq)
data ModifierTransaction = ModifierTransaction {
mtvalueexpr :: String,
mtpostings :: [Posting]
} deriving (Eq)
data PeriodicTransaction = PeriodicTransaction {
ptperiodicexpr :: String,
ptpostings :: [Posting]
} deriving (Eq)
data TimeLogCode = SetBalance | SetRequiredHours | In | Out | FinalOut deriving (Eq,Ord)
data TimeLogEntry = TimeLogEntry {
tlcode :: TimeLogCode,
tldatetime :: LocalTime,
tlcomment :: String
} deriving (Eq,Ord)
data HistoricalPrice = HistoricalPrice {
hdate :: Day,
hsymbol :: String,
hamount :: MixedAmount
} deriving (Eq)
data Journal = Journal {
jmodifiertxns :: [ModifierTransaction],
jperiodictxns :: [PeriodicTransaction],
jtxns :: [Transaction],
open_timelog_entries :: [TimeLogEntry],
historical_prices :: [HistoricalPrice],
final_comment_lines :: String,
filepath :: FilePath,
filereadtime :: ClockTime,
jtext :: String
} deriving (Eq)
data Account = Account {
aname :: AccountName,
apostings :: [Posting],
abalance :: MixedAmount
}
data Ledger = Ledger {
journal :: Journal,
accountnametree :: Tree AccountName,
accountmap :: Map.Map AccountName Account
} deriving Typeable
data FilterSpec = FilterSpec {
datespan :: DateSpan
,cleared :: Maybe Bool
,real :: Bool
,empty :: Bool
,costbasis :: Bool
,acctpats :: [String]
,descpats :: [String]
,whichdate :: WhichDate
,depth :: Maybe Int
} deriving (Show)