Safe Haskell | None |
---|
Penny - extensible double-entry accounting system
- data Version = Version {
- versionBranch :: [Int]
- versionTags :: [String]
- data Defaults = Defaults {
- caseSensitive :: Bool
- matcher :: Matcher
- colorToFile :: Bool
- expressionType :: ExprDesc
- defaultScheme :: Maybe Scheme
- additionalSchemes :: [Scheme]
- sorter :: [(SortField, SortOrder)]
- formatQty :: FormatQty
- balanceShowZeroBalances :: Bool
- balanceOrder :: SortOrder
- convertShowZeroBalances :: Bool
- convertTarget :: Target
- convertOrder :: SortOrder
- convertSortBy :: SortBy
- postingsFields :: Fields Bool
- postingsWidth :: Int
- postingsShowZeroBalances :: Bool
- postingsDateFormat :: (PostMeta, Posting) -> Text
- postingsSubAccountLength :: Int
- postingsPayeeAllocation :: Int
- postingsAccountAllocation :: Int
- postingsSpacers :: Spacers Int
- data Matcher
- data Scheme = Scheme {}
- type Changers = Labels (EvenAndOdd (Chunk -> Chunk))
- data Labels a = Labels {}
- data EvenAndOdd a = EvenAndOdd {}
- module System.Console.Rainbow
- data SortField
- = Payee
- | Date
- | Flag
- | Number
- | Account
- | DrCr
- | Qty
- | Commodity
- | PostingMemo
- | TransactionMemo
- data SortOrder
- = Ascending
- | Descending
- data ExprDesc
- data Target
- data SortBy
- = SortByQty
- | SortByName
- data Fields a = Fields {
- fGlobalTransaction :: a
- fRevGlobalTransaction :: a
- fGlobalPosting :: a
- fRevGlobalPosting :: a
- fFileTransaction :: a
- fRevFileTransaction :: a
- fFilePosting :: a
- fRevFilePosting :: a
- fFiltered :: a
- fRevFiltered :: a
- fSorted :: a
- fRevSorted :: a
- fVisible :: a
- fRevVisible :: a
- fLineNum :: a
- fDate :: a
- fFlag :: a
- fNumber :: a
- fPayee :: a
- fAccount :: a
- fPostingDrCr :: a
- fPostingCmdty :: a
- fPostingQty :: a
- fTotalDrCr :: a
- fTotalCmdty :: a
- fTotalQty :: a
- fTags :: a
- fMemo :: a
- fFilename :: a
- data Spacers a = Spacers {
- sGlobalTransaction :: a
- sRevGlobalTransaction :: a
- sGlobalPosting :: a
- sRevGlobalPosting :: a
- sFileTransaction :: a
- sRevFileTransaction :: a
- sFilePosting :: a
- sRevFilePosting :: a
- sFiltered :: a
- sRevFiltered :: a
- sSorted :: a
- sRevSorted :: a
- sVisible :: a
- sRevVisible :: a
- sLineNum :: a
- sDate :: a
- sFlag :: a
- sNumber :: a
- sPayee :: a
- sAccount :: a
- sPostingDrCr :: a
- sPostingCmdty :: a
- sPostingQty :: a
- sTotalDrCr :: a
- sTotalCmdty :: a
- widthFromRuntime :: Runtime -> Int
- yearMonthDay :: (PostMeta, Posting) -> Text
- data S3 a b c
- type FormatQty = [LedgerItem] -> Amount Qty -> Text
- qtyFormatter :: S3 Radix PeriodGrp CommaGrp -> FormatQty
- getQtyFormat :: S3 Radix PeriodGrp CommaGrp -> [LedgerItem] -> Amount Qty -> S3 Radix PeriodGrp CommaGrp
- data Radix
- data PeriodGrp
- = PGSpace
- | PGThinSpace
- | PGComma
- data CommaGrp
- = CGSpace
- | CGThinSpace
- | CGPeriod
- data Runtime
- environment :: Runtime -> [(String, String)]
- data Text
- pack :: String -> Text
- runPenny :: Version -> (Runtime -> Defaults) -> IO ()
Building a custom Penny binary
Everything you need to create a custom Penny program is available by importing only this module.
data Version
A Version
represents the version of a software entity.
An instance of Eq
is provided, which implements exact equality
modulo reordering of the tags in the versionTags
field.
An instance of Ord
is also provided, which gives lexicographic
ordering on the versionBranch
fields (i.e. 2.1 > 2.0, 1.2.3 > 1.2.2,
etc.). This is expected to be sufficient for many uses, but note that
you may need to use a more specific ordering for your versioning
scheme. For example, some versioning schemes may include pre-releases
which have tags "pre1"
, "pre2"
, and so on, and these would need to
be taken into account when determining ordering. In some cases, date
ordering may be more appropriate, so the application would have to
look for date
tags in the versionTags
field and compare those.
The bottom line is, don't always assume that compare
and other Ord
operations are the right thing for every Version
.
Similarly, concrete representations of versions may differ. One
possible concrete representation is provided (see showVersion
and
parseVersion
), but depending on the application a different concrete
representation may be more appropriate.
Version | |
|
This type contains settings for all the reports, as well as default settings for the global options. Some of these can be overridden on the command line.
Defaults | |
|
Color schemes
module System.Console.Rainbow
Sorting
Expression type
Convert report options
The commodity to which to convert the commodities in the convert report.
AutoTarget | Selects a target commodity automatically, based on which commodity is the most common target commodity in the prices in your ledger files. If there is a tie for most common target commodity, the target that appears later in your ledger files is used. |
ManualTarget String | Always uses the commodity named by the string given. |
Postings report options
Fields | |
|
Spacers | |
|
widthFromRuntime :: Runtime -> IntSource
Gets the current screen width from the runtime. If the COLUMNS environment variable is not set, uses 80.
yearMonthDay :: (PostMeta, Posting) -> TextSource
Shows the date of a posting in YYYY-MM-DD format.
Formatting quantities
data S3 a b c
= [LedgerItem] | All parsed items |
-> Amount Qty | |
-> Text |
A function used to format quantities.
:: S3 Radix PeriodGrp CommaGrp | What to do if no radix or grouping information can be determined from the ledger. Pass Radix if you want to use a radix point but no grouping; a PeriodGrp if you want to use a period for a radix point and the given grouping character, or a CommaGrp if you want to use a comma for a radix point and the given grouping character. |
-> FormatQty |
Provides a function to use in the formatQty
field. This formats
quantities that were not parsed in the ledger. It first consults a
list of all items that were parsed from the ledger. It examines
these items to determine if another item with the same commodity
already exists in the ledger.
If other items with the same commodity exist in the ledger, the radix point most frequently occurring amongst those items is used. If at least one of these items (with this radix point) also has grouped digits, then the quantity will be formatted with grouped digits; otherwise, no digit grouping is performed. If digit grouping is performed, it is done according to the following rules:
- only digits to the left of the radix point are grouped
- grouping is performed only if the number has at least five digits. Therefore, 1234 is not grouped, but 1,234.5 is grouped, as is 12,345
- the character most frequently appearing as a grouping character (for this particular commodity and radix point) is used to perform grouping
- digits are grouped into groups of 3 digits
If a radix point cannot be determined from the quantities for a given commodity, then the radix point appearing most frequently for all commodities is used. If it's impossible to determine a radix point from all commodities, then the given default radix point and digit grouping (if desired) is used.
This function builds a map internally which holds all the formatting information; it might be expensive to build, so the function is written to be partially applied.
:: S3 Radix PeriodGrp CommaGrp | What to do if no radix or grouping information can be determined from the ledger. Pass Radix if you want to use a radix point but no grouping; a PeriodGrp if you want to use a period for a radix point and the given grouping character, or a CommaGrp if you want to use a comma for a radix point and the given grouping character. |
-> [LedgerItem] | |
-> Amount Qty | |
-> S3 Radix PeriodGrp CommaGrp |
Obtains radix and grouping information for a particular commodity and quantity, but does not actually perform the formatting.
The digit grouping character when the radix is a period.
PGSpace | ASCII space |
PGThinSpace | Unicode code point 0x2009 |
PGComma | Comma |
The digit grouping character when the radix is a comma.
CGSpace | ASCII space |
CGThinSpace | Unicode code point 0x2009 |
CGPeriod | Period |
Runtime
environment :: Runtime -> [(String, String)]Source
Text
data Text
A space efficient, packed, unboxed Unicode text type.
Main function
:: Version | Version of the executable |
-> (Runtime -> Defaults) | runPenny will apply this function to the Runtime. This way the defaults you use can vary depending on environment variables, the terminal type, the date, etc. |
-> IO () |
Creates an IO action that you can use for the main function.
Developer overview
Penny is organized into a tree of modules, each with a name. Check out the links for details on each component of Penny.
Penny.Brenner - Penny financial institution transaction handling. Depends on Lincoln and Copper.
Penny.Cabin - Penny reports. Depends on Lincoln and Liberty.
Penny.Copper - the Penny parser. Depends on Lincoln.
Penny.Liberty - Penny command line parser helpers. Depends on Lincoln and Copper.
Penny.Lincoln - the Penny core. Depends on no other Penny components.
Penny.Shield - the Penny runtime environment. Depends on Lincoln.
Penny.Steel - independent utilities. Depends on no other Penny components.
Penny.Wheat - helping you build your own programs to check your ledger. Depends on Steel, Lincoln, and Copper.
Penny.Zinc - the Penny command-line interface. Depends on Cabin, Copper, Liberty, and Lincoln.
The dependencies are represented as a dot file in
doc/dependencies.dot
in the Penny git repository.