penny-lib-0.4.0.0: Extensible double-entry accounting system - library

Safe HaskellSafe-Infered

Penny.Lincoln.Bits

Contents

Description

Essential data types used to make Transactions and Postings.

Synopsis

Accounts

Amounts

data Amount Source

Constructors

Amount 

Fields

qty :: Qty
 
commodity :: Commodity
 

Instances

Commodities

charCommodity :: Char -> CommoditySource

Creates a Commodity whose name is only a single character.

DateTime

data DateTime Source

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

data DrCr Source

Constructors

Debit 
Credit 

Instances

opposite :: DrCr -> DrCrSource

Debit returns Credit; Credit returns Debit

Entries

data Entry Source

Constructors

Entry 

Fields

drCr :: DrCr
 
amount :: Amount
 

Instances

Flag

newtype Flag Source

Constructors

Flag 

Fields

unFlag :: TextNonEmpty
 

Memos

newtype Memo Source

Constructors

Memo 

Fields

unMemo :: [MemoLine]
 

Number

Payee

Prices and price points

newtype From Source

Constructors

From 

Fields

unFrom :: Commodity
 

Instances

newtype To Source

Constructors

To 

Fields

unTo :: Commodity
 

Instances

data Price Source

Instances

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

data Qty Source

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.

Instances

unQty :: Qty -> DecimalSource

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.

add :: Qty -> Qty -> QtySource

difference :: Qty -> Qty -> DifferenceSource

Subtract the second Qty from the first.

Tags

newtype Tag Source

Constructors

Tag 

Fields

unTag :: TextNonEmpty
 

newtype Tags Source

Constructors

Tags 

Fields

unTags :: [Tag]