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

Safe HaskellSafe-Infered

Penny.Copper.Qty

Contents

Synopsis

Setting the radix and separator characters

periodComma :: RadGroupSource

Radix is period, grouping is comma

periodSpace :: RadGroupSource

Radix is period, grouping is space

commaPeriod :: RadGroupSource

Radix is comma, grouping is period

commaSpace :: RadGroupSource

Radix is comma, grouping is space

Rendering

data GroupingSpec Source

Specifies how to perform digit grouping when rendering a quantity. All grouping groups into groups of 3 digits.

Constructors

NoGrouping

Do not perform any digit grouping

GroupLarge

Group digits, but only if the number to be grouped is greater than 9,999 (if grouping the whole part) or if there are more than 4 decimal places (if grouping the fractional part).

GroupAll

Group digits whenever there are at least four decimal places.

renderUnquotedSource

Arguments

:: RadGroup 
-> (GroupingSpec, GroupingSpec)

Group for the portion to the left and right of the radix point?

-> Qty 
-> Text 

Renders an unquoted Qty. Performs digit grouping as requested.

quote :: Text -> TextSource

Quotes a rendered Qty, but only if necessary; otherwise, simply leaves it unquoted.

Parsing quantities

qtyUnquoted :: RadGroup -> Parser QtySource

Unquoted quantity. These include no spaces, regardless of what the grouping character is.

qtyQuoted :: RadGroup -> Parser QtySource

Parse quoted quantity. It can include spaces, if the grouping character is a space. However these must be quoted when in a Ledger file (from the command line they need not be quoted). The quote character is a caret, ^.

qty :: RadGroup -> Parser QtySource

Parse a quoted quantity or, if that fails, an unquoted quantity.