reports::PivotTable Class Reference

#include <pivottable.h>

Inheritance diagram for reports::PivotTable:

Collaboration diagram for reports::PivotTable:

Collaboration graph

List of all members.

Public Member Functions

 PivotTable (const MyMoneyReport &_config_f)
virtual ~PivotTable ()
QString renderHTML (void) const
QString renderCSV (void) const
void drawChart (KReportChartView &view) const
void dump (const QString &file, const QString &context=QString()) const
PivotGrid grid (void)

Protected Member Functions

void init (void)
void createRow (const QString &outergroup, const ReportAccount &row, bool recursive)
void assignCell (const QString &outergroup, const ReportAccount &row, unsigned column, MyMoneyMoney value, bool budget=false, bool stockSplit=false)
void createAccountRows (void)
void calculateOpeningBalances (void)
void calculateBudgetMapping (void)
void calculateRunningSums (void)
void calculateRunningSums (PivotInnerGroup::iterator &it_row)
void calculateBudgetDiff (void)
void calculateForecast (void)
void fillBasePriceUnit (ERowType rowType)
void calculateMovingAverage (void)
void calculateTotals (void)
void convertToBaseCurrency (void)
void convertToDeepCurrency (void)
void collapseColumns (void)
void calculateColumnHeadings (void)
void accumulateColumn (unsigned destcolumn, unsigned sourcecolumn)
void clearColumn (unsigned column)
unsigned columnValue (const QDate &_date) const
QDate columnDate (int column) const
MyMoneyMoney cellBalance (const QString &outergroup, const ReportAccount &_row, unsigned column, bool budget)
unsigned drawChartRowSet (unsigned rowNum, const bool seriesTotals, const bool accountSeries, KDChartTableData &data, const PivotGridRowSet &rowSet, const ERowType rowType) const
void loadRowTypeList (void)
void includeInvestmentSubAccounts (void)

Private Member Functions

QString coloredAmount (const MyMoneyMoney &amount, const QString &currencySymbol=QString(), int prec=2) const

Private Attributes

PivotGrid m_grid
QStringList m_columnHeadings
unsigned m_numColumns
QDate m_beginDate
QDate m_endDate
bool m_runningSumsCalculated
QMap< QString, QString > m_budgetMap
QValueList< ERowTypem_rowTypeList
QValueList< QString > m_columnTypeHeaderList
MyMoneyReport m_config_f

Detailed Description

Calculates a 'pivot table' of information about the transaction database. Based on pivot tables in MS Excel, and implemented as 'Data Pilot' in OpenOffice.Org Calc.

| Month,etc -------------+------------ Expense Type | Sum(Value) Category |

This is a middle-layer class, between the UI and the engine. The MyMoneyReport class holds only the CONFIGURATION parameters. This class actually does the work of retrieving the data from the engine and formatting it for the user.

Ace Jones

Constructor & Destructor Documentation

reports::PivotTable::PivotTable ( const MyMoneyReport _config_f  ) 

Create a Pivot table style report

_config_f The configuration parameters for this report

virtual reports::PivotTable::~PivotTable (  )  [inline, virtual]

virtual Destructur

Member Function Documentation

QString reports::PivotTable::renderHTML ( void   )  const [virtual]

Render the report to an HTML stream.

QString HTML string representing the report

Implements reports::ReportTable.

QString reports::PivotTable::renderCSV ( void   )  const [virtual]

Render the report to a comma-separated-values stream.

QString CSV string representing the report

Implements reports::ReportTable.

void reports::PivotTable::drawChart ( KReportChartView view  )  const [virtual]

Render the report to a graphical chart

view The KReportChartView into which to draw the chart.

Implements reports::ReportTable.

void reports::PivotTable::dump ( const QString &  file,
const QString &  context = QString() 
) const [virtual]

Dump the report's HTML to a file

file The filename to dump into
context unused, but provided for interface compatibility

Implements reports::ReportTable.

PivotGrid reports::PivotTable::grid ( void   )  [inline]

Returns the grid generated by the report

void reports::PivotTable::init ( void   )  [protected]

QString reports::PivotTable::coloredAmount ( const MyMoneyMoney amount,
const QString &  currencySymbol = QString(),
int  prec = 2 
) const [private]

This method returns the formatted value of amount with a possible currencySymbol added and prec fractional digits. currencySymbol defaults to be empty and prec defaults to 2.

If amount is negative the formatted value is enclosed in an HTML font tag to modify the color to reflect the user settings for negtive numbers.

Example: 1.23 is returned as '1.23' whereas -1.23 is returned as

<font color="rgb($red,$green,$blue)">-1.23</font>
with $red, $green and $blue being the actual value for the chosen color.

void reports::PivotTable::createRow ( const QString &  outergroup,
const ReportAccount row,
bool  recursive 
) [protected]

Creates a row in the grid if it doesn't already exist

Downsteam assignment functions will assume that this row already exists, so this function creates a row of the needed length populated with zeros.

outergroup The outer row group
row The row itself
recursive Whether to also recursively create rows for our parent accounts

void reports::PivotTable::assignCell ( const QString &  outergroup,
const ReportAccount row,
unsigned  column,
MyMoneyMoney  value,
bool  budget = false,
bool  stockSplit = false 
) [inline, protected]

Assigns a value into the grid

Adds the given value to the value which already exists at the specified grid position

outergroup The outer row group
row The row itself
column The column
value The value to be added in
budget Whether this is a budget value (true) or an actual value (false). Defaults to false.
stockSplit Wheter this is a stock split (true) or an actual value (false). Defaults to false.

void reports::PivotTable::createAccountRows ( void   )  [protected]

Create a row for each included account. This is used when the config parameter isIncludingUnusedAccount() is true

void reports::PivotTable::calculateOpeningBalances ( void   )  [protected]

Record the opening balances of all qualifying accounts into the grid.

For accounts opened before the report period, places the balance into the '0' column. For those opened during the report period, places the balance into the appropriate column for the month when it was opened.

void reports::PivotTable::calculateBudgetMapping ( void   )  [protected]

Calculate budget mapping

For budget-vs-actual reports, this creates a mapping between each account in the user's hierarchy and the account where the budget is held for it. This is needed because the user can budget on a given account for that account and all its descendants. Also if NO budget is placed on the account or any of its parents, the account is not included in the map.

void reports::PivotTable::calculateRunningSums ( void   )  [protected]

Calculate the running sums.

After calling this method, each cell of the report will contain the running sum of all the cells in its row in this and earlier columns.

For example, consider a row with these values: 01 02 03 04 05 06 07 08 09 10

After calling this function, the row will look like this: 01 03 06 10 15 21 28 36 45 55

void reports::PivotTable::calculateRunningSums ( PivotInnerGroup::iterator &  it_row  )  [protected]

void reports::PivotTable::calculateBudgetDiff ( void   )  [protected]

This method calculates the difference between a budgeted and an actual amount. The calculation is based on the type of the repAccount. The difference value is calculated as follows:

If repAccount is of type MyMoneyAccount::Income

      diff = actual - budgeted

If repAccount is of type MyMoneyAccount::Expense

      diff = budgeted - actual

In all other cases, 0 is returned.

void reports::PivotTable::calculateForecast ( void   )  [protected]

This method calculates forecast for a report

void reports::PivotTable::fillBasePriceUnit ( ERowType  rowType  )  [protected]

This method inserts units to be used to display prices

void reports::PivotTable::calculateMovingAverage ( void   )  [protected]

This method calculates moving average for a report

void reports::PivotTable::calculateTotals ( void   )  [protected]

Calculate the row and column totals

This function will set the m_total members of all the TGrid objects. Be sure the values are all converted to the base currency first!!

void reports::PivotTable::convertToBaseCurrency ( void   )  [protected]

Convert each value in the grid to the base currency

void reports::PivotTable::convertToDeepCurrency ( void   )  [protected]

Convert each value in the grid to the account/category's deep currency

See AccountDescriptor::deepCurrencyPrice() for a description of 'deep' currency

void reports::PivotTable::collapseColumns ( void   )  [protected]

Turn month-long columns into larger time periods if needed

For example, consider a row with these values: 01 02 03 04 05 06 07 08 09 10

If the column pitch is 3 (i.e. quarterly), after calling this function, the row will look like this: 06 15 26 10

void reports::PivotTable::calculateColumnHeadings ( void   )  [protected]

Determine the proper column headings based on the time periods covered by each column

void reports::PivotTable::accumulateColumn ( unsigned  destcolumn,
unsigned  sourcecolumn 
) [protected]

Helper methods for collapseColumns

void reports::PivotTable::clearColumn ( unsigned  column  )  [protected]

unsigned reports::PivotTable::columnValue ( const QDate &  _date  )  const [protected]

Calculate the column of a given date. This is the absolute column in a hypothetical report that covers all of known time. In reality an actual report will be a subset of that.

_date The date

QDate reports::PivotTable::columnDate ( int  column  )  const [protected]

Calculate the date of the last day covered by a given column.

column The column

MyMoneyMoney reports::PivotTable::cellBalance ( const QString &  outergroup,
const ReportAccount _row,
unsigned  column,
bool  budget 
) [protected]

Returns the balance of a given cell. Throws an exception once calculateRunningSums() has been run.

unsigned reports::PivotTable::drawChartRowSet ( unsigned  rowNum,
const bool  seriesTotals,
const bool  accountSeries,
KDChartTableData data,
const PivotGridRowSet rowSet,
const ERowType  rowType 
) const [protected]

Draws a PivotGridRowSet in a chart for the given ERowType

void reports::PivotTable::loadRowTypeList ( void   )  [protected]

Loads m_rowTypeList with the list of PivotGridRow types that the reporttable should show

void reports::PivotTable::includeInvestmentSubAccounts ( void   )  [protected]

If not in expert mode, include all subaccounts for each selected investment account

Member Data Documentation

QMap<QString, QString> reports::PivotTable::m_budgetMap [private]

For budget-vs-actual reports only, maps each account to the account which holds the budget for it. If an account is not contained in this map, it is not included in the budget.

This list contains the types of PivotGridRows that are going to be shown in the report

This list contains the i18n headers for the column types

The documentation for this class was generated from the following file:

Generated on Wed Jan 26 13:11:43 2011 for KMyMoney by  doxygen 1.5.6