penny-0.32.0.6: Extensible double-entry accounting system

Safe HaskellNone

Penny.Cabin.Posts.Allocated

Description

Calculates the allocated cells -- the Payee cell and the Account cell. Here is the logic for this process:

  1. If neither Payee nor Account appears, do nothing.
  2. Obtain the width of the growing cells, including the spacers. One of the spacers attached to a field might be omitted:

a. If the rightmost growing field is TotalQty, include all spacers.

b. If the rightmost growing field is to the left of Payee, include all spacers.

c. If the rightmost growing field is to the right of Account but is not TotalQty, omit its spacer.

  1. Obtain the width of the Payee and Account spacers. Include each spacer if its corresponding field appears in the report.
  2. Subtract from the total report width the width of the the growing cells and the width of the Payee and Account spacers. This gives the total width available for the Payee and Account fields. If there are not at least two columns available, return without including the Payee and Account fields.
  3. Determine the total width that the Payee and Account fields would obtain if they had all the space they could ever need. This is the requested width.
  4. Split up the available width for the Payee and Account fields depending on which fields appear:

a. If only the one field appears, then it shall be as wide as the total available width or the its requested width, whichever is smaller.

b. If both fields appear, then calculate the allocated width for each field. If either field's requested width is less than its allocated width, then that field is only as wide as its requested width. The other field is then as wide as (the sum of its allocated width and the leftover width from the other field) or its requested width, whichever is smaller. If neither field's requested width is less than its allocated width, then each field gets ts allocated width.

  1. Fill cell contents; return filled cells.

Synopsis

Documentation

payeeAndAcct :: Changers -> AllocatedOpts -> [(PostMeta, Posting)] -> Fields (Maybe ([ColumnSpec], Int))Source

Creates Payee and Account cells. The user must have requested the cells. In addition, no cells are created if there is not enough space for them in the report. Returns a Fields; each element of the Fields is Nothing if no cells were created (either because the user did not ask for them, or because there was no room) or Just cs i, where cs is a list of all the cells, and i is the width of all the cells.

data AllocatedOpts Source

All the information needed for allocated cells.

data Fields a Source

Constructors

Fields 

Fields

payee :: a
 
account :: a
 

data Alloc Source

Instances