GnuCashew ~ GnuCash Enabled Web
GCW
Public Member Functions | Private Member Functions | Private Attributes | List of all members
GCW::Gui::BillPay::Model Class Reference

Data Model. More...

#include <Model.h>

Inherits Wt::WStandardItemModel.

Public Member Functions

 Model (int _selectedMonth, Status _status)
 ctor More...
 
auto columnDef (int _col) -> ColumnDef_t
 Column Definition. More...
 
auto loadData (int _selectedMonth) -> void
 Reload the data based on the selected month. More...
 

Private Member Functions

auto sort (std::vector< GCW::Gui::BillPay::Item > &_bpItems) -> void
 Sorter. More...
 

Private Attributes

Status m_status
 Model Status. More...
 

Detailed Description

Data Model.

Contains paid, unpaid and disabled accounts.

When constructing the Model, the parameters control the subset of items that will appear in the model. Therefore, the final model contains only 'paid', 'unpaid' or 'disabled' items for the month selected.

Definition at line 52 of file Model.h.

Constructor & Destructor Documentation

◆ Model()

GCW::Gui::BillPay::Model::Model ( int  _selectedMonth,
Status  _status 
)

ctor

During construction, the model examines all the billpay-items to detemine if the item meets the parameter criteria. This allows a TableView to be constructed to present the items that meet this criteria as a grouped set of items.

To return all the items in the month of February that are 'paid', the constructor would appear as follows;

auto model = std::make_shared< Model >( 2, BillPay::Status::Paid );
Parameters
_selectedMonthSelect a 'calendar month' to compare status
_statusSelect a BillPay::Status to evaluate to

Definition at line 43 of file Model.cpp.

References COLUMN_COUNT, loadData(), m_status, GCW::Dbo::Accounts::Field::name, and GCW::Gui::BillPay::Unpaid.

Member Function Documentation

◆ columnDef()

auto GCW::Gui::BillPay::Model::columnDef ( int  _col) -> ColumnDef_t

Column Definition.

Return the column definition for the selected column.

Definition at line 274 of file Model.cpp.

◆ loadData()

auto GCW::Gui::BillPay::Model::loadData ( int  _selectedMonth) -> void

Reload the data based on the selected month.

This will drop all the data in the model and reload it with the month selected.

On load, the first column-label is set to indicate the model type as well as the month selected.

Change the label on the column-0, example;
"03 Unpaid"
"06 Paid"
"12 Disabled"

On load, all existing data in the model is first dumped.

Get all the var items that are for the 'managed bill pay item' (mbpi) in to a resultList that will then be used to load the resulting model.

Run the resultList collection through an analyzer that will extract billpay items that match the selection criteria of paid/unpaid/disabled/yes/no accordingly.

Sort all the items by the account group.dueDay. (The user is not allowed to sort these views so we do it) This sorts the items with the items that are due first, above those that are due next.

Each item is processed out of the sorted vector and placed in to the item model.

While building the 'month columns', apply a style class to the column of items according to the month selected. This causes the current selected column to be highlighted within the table view in the browser.

Definition at line 77 of file Model.cpp.

References GCW::app(), GCW::Gui::BillPay::asString(), GCW::Gui::BillPay::bpItem(), GCW::Dbo::Accounts::byGuid(), GCW::Gui::BillPay::Disabled, GCW::Dbo::Accounts::fullName(), GCW_GUI_BILLPAY_ITEM_CFY, GCW::Dbo::Accounts::Field::name, GCW::Gui::BillPay::Paid, GCW::Gui::BillPay::toString(), and GCW::Gui::BillPay::Unpaid.

Referenced by Model().

◆ sort()

auto GCW::Gui::BillPay::Model::sort ( std::vector< GCW::Gui::BillPay::Item > &  _bpItems) -> void
private

Sorter.

This sorter produces a sorted list of bills-to-pay sorted by first 'group' then 'dueDay'. This produces a number that might be like 20.22, meaning group=20, day=22. The result in the view is all the "due next" items at the top of the list, and so on. The group-value is to just help clean the display. The result makes it very clear what bills are due next in line.

Sort the vector of bpItems by group.dueDay

Definition at line 281 of file Model.cpp.

Member Data Documentation

◆ m_status

Status GCW::Gui::BillPay::Model::m_status
private

Model Status.

Each model represents items of a partcular status. The model set contains, therefore, only items that match the selected status and the selected month.

Definition at line 123 of file Model.h.

Referenced by Model().


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