Safe Haskell | Safe-Infered |
---|
Essential data types used to make Transactions and Postings.
- newtype SubAccountName = SubAccountName {}
- newtype Account = Account {}
- data Amount = Amount {}
- newtype Commodity = Commodity {}
- newtype SubCommodity = SubCommodity {}
- charCommodity :: Char -> Commodity
- data DateTime
- dateTime :: LocalTime -> TimeZoneOffset -> DateTime
- localTime :: DateTime -> LocalTime
- timeZone :: DateTime -> TimeZoneOffset
- data TimeZoneOffset
- minsToOffset :: Int -> Maybe TimeZoneOffset
- offsetToMins :: TimeZoneOffset -> Int
- noOffset :: TimeZoneOffset
- data DrCr
- opposite :: DrCr -> DrCr
- data Entry = Entry {}
- newtype Flag = Flag {}
- newtype MemoLine = MemoLine {}
- newtype Memo = Memo {}
- newtype Number = Number {}
- newtype Payee = Payee {}
- newtype From = From {}
- newtype To = To {}
- newtype CountPerUnit = CountPerUnit {}
- data Price
- convert :: Price -> Amount -> Maybe Amount
- newPrice :: From -> To -> CountPerUnit -> Maybe Price
- data PricePoint = PricePoint DateTime Price PriceMeta
- data Qty
- unQty :: Qty -> Decimal
- partialNewQty :: Decimal -> Qty
- newQty :: Decimal -> Maybe Qty
- add :: Qty -> Qty -> Qty
- subt :: Qty -> Qty -> Maybe Qty
- mult :: Qty -> Qty -> Qty
- zero :: Qty
- difference :: Qty -> Qty -> Difference
- data Difference
- = LeftBiggerBy Qty
- | RightBiggerBy Qty
- | Equal
- newtype Tag = Tag {}
- newtype Tags = Tags {}
Accounts
newtype SubAccountName Source
Amounts
Commodities
newtype SubCommodity Source
charCommodity :: Char -> CommoditySource
Creates a Commodity whose name is only a single character.
DateTime
A DateTime is a UTC time that also remembers the local time from which it was set. The Eq and Ord instances will compare two DateTimes based on their equivalent UTC times.
dateTime :: LocalTime -> TimeZoneOffset -> DateTimeSource
Construct a DateTime.
data TimeZoneOffset Source
The number of minutes that this timezone is offset from UTC. Can be positive, negative, or zero.
minsToOffset :: Int -> Maybe TimeZoneOffsetSource
Convert minutes to a time zone offset. I'm having a hard time deciding whether to be liberal or strict in what to accept here. Currently it is somewhat strict in that it will fail if absolute value is greater than 840 minutes; currently the article at http:en.wikipedia.orgwikiList_of_time_zones_by_UTC_offset says there is no offset greater than 14 hours, or 840 minutes.
Debits and Credits
Entries
Flag
Memos
Number
Payee
Prices and price points
newtype CountPerUnit Source
convert :: Price -> Amount -> Maybe AmountSource
Convert an amount from the From price to the To price. Fails if the From commodity in the Price is not the same as the commodity in the Amount.
newPrice :: From -> To -> CountPerUnit -> Maybe PriceSource
Succeeds only if From and To are different commodities.
Quantities
A quantity is always greater than zero. Various odd questions happen if quantities can be zero. For instance, what if you have a debit whose quantity is zero? Does it require a balancing credit that is also zero? And how can you have a debit of zero anyway?
I can imagine situations where a quantity of zero might be useful; for instance maybe you want to specifically indicate that a particular posting in a transaction did not happen (for instance, that a paycheck deduction did not take place). I think the better way to handle that though would be through an addition to DebitCredit - maybe DebitCredit/Zero. Barring the addition of that, though, the best way to indicate a situation such as this would be through transaction memos.
Unwrap a Qty to get the underlying Decimal. This Decimal will always be greater than zero.
partialNewQty :: Decimal -> QtySource
Make a new Qty. This function is partial. It will call error if its argument is less than or equal to zero.
newQty :: Decimal -> Maybe QtySource
Make a new Qty. Returns Nothing if its argument is less than zero.
difference :: Qty -> Qty -> DifferenceSource
Subtract the second Qty from the first.