GnuCashew ~ Web Application compatible with GnuCash sql data files.
GCW
|
Account Register Model. More...
#include <Model.h>
Public Member Functions | |
Model () | |
ctor | |
auto | setAccountGuid (const std::string &_accountGuid) -> void |
auto | refreshFromDisk () -> void |
Refresh From Disk. | |
auto | saveToDisk () -> void |
auto | viewMode () const -> ViewMode |
auto | setViewMode (ViewMode _viewMode) -> void |
auto | doubleLine () const -> bool |
auto | setDoubleLine (bool _doubleLine) -> void |
auto | splitCount () -> int |
Split Count. | |
auto | isDeletable (const Wt::WModelIndex &_index) -> bool |
Is Read Only. | |
auto | isJumpable (const Wt::WModelIndex &_index) -> bool |
Is Jumpable. | |
auto | isReadOnly () -> bool |
auto | isReadOnly (int _row) -> bool |
auto | isReadOnly (const Wt::WModelIndex &_index) -> bool |
auto | setReadOnly (bool _state) |
auto | getSplitGuid (const Wt::WModelIndex &_index) -> std::string |
Get GUID from row. | |
auto | getSplitGuid (int _row) -> std::string |
auto | getDate (const Wt::WModelIndex &_index) -> Wt::WDateTime |
Get Date from the index. | |
auto | getAction (const Wt::WModelIndex &_index) -> std::string |
Get Action. | |
auto | getDescription (const Wt::WModelIndex &_index) -> std::string |
Get Description. | |
auto | getTransferText (const Wt::WModelIndex &_index) -> std::string |
Get Transfer Account Text. | |
auto | getTransferGuid (const Wt::WModelIndex &_index) -> std::string |
Get Transfer Account GUID. | |
auto | getReconcile (const Wt::WModelIndex &_index) -> std::string |
Get Reconciliation. | |
auto | getNumeric (const Wt::WModelIndex &_index) -> GCW_NUMERIC |
Get numeric value. | |
auto | getDebit (const Wt::WModelIndex &_index) -> GCW_NUMERIC |
Get Debit value. | |
auto | getCredit (const Wt::WModelIndex &_index) -> GCW_NUMERIC |
Get Credit value. | |
auto | getValue (const Wt::WModelIndex &_index) -> GCW_NUMERIC |
Get Value (positive or negative) | |
auto | getBalance (const Wt::WModelIndex &_index) -> GCW_NUMERIC |
Get Balance (positive or negative) | |
auto | present () const -> GCW_NUMERIC |
auto | future () const -> GCW_NUMERIC |
auto | cleared () const -> GCW_NUMERIC |
auto | reconciled () const -> GCW_NUMERIC |
auto | projected () const -> GCW_NUMERIC |
auto | makeRow (const std::string &_splitGuid) -> RowItem |
auto | suggestionsFromColumn (int _column) const -> std::set< std::string > |
Column Suggestions. | |
auto | setData (const Wt::WModelIndex &_index, const Wt::cpp17::any &_value, Wt::ItemDataRole _role) -> bool |
auto | goneDirty () -> Wt::Signal< Wt::WModelIndex > & |
![]() | |
WStandardItemModel () | |
WStandardItemModel (int rows, int columns) | |
~WStandardItemModel () | |
void | clear () |
WStandardItem * | invisibleRootItem () const |
WModelIndex | indexFromItem (const WStandardItem *item) const |
WStandardItem * | itemFromIndex (const WModelIndex &index) const |
void | appendColumn (std::vector< std::unique_ptr< WStandardItem > > items) |
void | insertColumn (int column, std::vector< std::unique_ptr< WStandardItem > > items) |
void | appendRow (std::vector< std::unique_ptr< WStandardItem > > items) |
void | insertRow (int row, std::vector< std::unique_ptr< WStandardItem > > items) |
void | appendRow (std::unique_ptr< WStandardItem > item) |
void | insertRow (int row, std::unique_ptr< WStandardItem > item) |
WStandardItem * | item (int row, int column=0) const |
void | setItem (int row, int column, std::unique_ptr< WStandardItem > item) |
WStandardItem * | itemPrototype () const |
void | setItemPrototype (std::unique_ptr< WStandardItem > item) |
std::vector< std::unique_ptr< WStandardItem > > | takeColumn (int column) |
std::vector< std::unique_ptr< WStandardItem > > | takeRow (int row) |
std::unique_ptr< WStandardItem > | takeItem (int row, int column=0) |
void | setHeaderFlags (int section, Orientation orientation, WFlags< HeaderFlag > flags) |
void | setSortRole (ItemDataRole role) |
ItemDataRole | sortRole () const |
virtual void | sort (int column, SortOrder order=SortOrder::Ascending) override |
Signal< WStandardItem * > & | itemChanged () |
bool | insertRow (int row, const WModelIndex &parent=WModelIndex()) |
bool | insertColumn (int column, const WModelIndex &parent=WModelIndex()) |
![]() | |
WAbstractItemModel () | |
virtual int | columnCount (const WModelIndex &parent=WModelIndex()) const=0 |
virtual int | rowCount (const WModelIndex &parent=WModelIndex()) const=0 |
virtual WFlags< ItemFlag > | flags (const WModelIndex &index) const |
virtual WFlags< HeaderFlag > | headerFlags (int section, Orientation orientation=Orientation::Horizontal) const |
virtual bool | hasChildren (const WModelIndex &index) const |
virtual WModelIndex | parent (const WModelIndex &index) const=0 |
virtual cpp17::any | data (const WModelIndex &index, ItemDataRole role=ItemDataRole::Display) const=0 |
virtual DataMap | itemData (const WModelIndex &index) const |
virtual cpp17::any | headerData (int section, Orientation orientation=Orientation::Horizontal, ItemDataRole role=ItemDataRole::Display) const |
virtual WModelIndex | index (int row, int column, const WModelIndex &parent=WModelIndex()) const=0 |
virtual WModelIndexList | match (const WModelIndex &start, ItemDataRole role, const cpp17::any &value, int hits=-1, WFlags< MatchFlag > flags=WFlags< MatchFlag >(MatchFlag::StartsWith|MatchFlag::Wrap)) const |
cpp17::any | data (int row, int column, ItemDataRole role=ItemDataRole::Display, const WModelIndex &parent=WModelIndex()) const |
virtual bool | hasIndex (int row, int column, const WModelIndex &parent=WModelIndex()) const |
virtual bool | insertColumns (int column, int count, const WModelIndex &parent=WModelIndex()) |
virtual bool | insertRows (int row, int count, const WModelIndex &parent=WModelIndex()) |
virtual bool | removeColumns (int column, int count, const WModelIndex &parent=WModelIndex()) |
virtual bool | removeRows (int row, int count, const WModelIndex &parent=WModelIndex()) |
virtual bool | setData (const WModelIndex &index, const cpp17::any &value, ItemDataRole role=ItemDataRole::Edit) |
virtual bool | setItemData (const WModelIndex &index, const DataMap &values) |
virtual bool | setHeaderData (int section, Orientation orientation, const cpp17::any &value, ItemDataRole role=ItemDataRole::Edit) |
bool | setHeaderData (int section, const cpp17::any &value) |
virtual void | expandColumn (int column) |
virtual void | collapseColumn (int column) |
virtual void * | toRawIndex (const WModelIndex &index) const |
virtual WModelIndex | fromRawIndex (void *rawIndex) const |
virtual std::string | mimeType () const |
virtual std::vector< std::string > | acceptDropMimeTypes () const |
virtual void | dropEvent (const WDropEvent &e, DropAction action, int row, int column, const WModelIndex &parent) |
virtual void | dropEvent (const WDropEvent &e, DropAction action, const WModelIndex &index, Wt::Side side) |
bool | insertColumn (int column, const WModelIndex &parent=WModelIndex()) |
bool | insertRow (int row, const WModelIndex &parent=WModelIndex()) |
bool | removeColumn (int column, const WModelIndex &parent=WModelIndex()) |
bool | removeRow (int row, const WModelIndex &parent=WModelIndex()) |
bool | setData (int row, int column, const cpp17::any &value, ItemDataRole role=ItemDataRole::Edit, const WModelIndex &parent=WModelIndex()) |
virtual Signal< WModelIndex, int, int > & | columnsAboutToBeInserted () |
virtual Signal< WModelIndex, int, int > & | columnsAboutToBeRemoved () |
virtual Signal< WModelIndex, int, int > & | columnsInserted () |
virtual Signal< WModelIndex, int, int > & | columnsRemoved () |
virtual Signal< WModelIndex, int, int > & | rowsAboutToBeInserted () |
virtual Signal< WModelIndex, int, int > & | rowsAboutToBeRemoved () |
virtual Signal< WModelIndex, int, int > & | rowsInserted () |
virtual Signal< WModelIndex, int, int > & | rowsRemoved () |
virtual Signal< WModelIndex, WModelIndex > & | dataChanged () |
virtual Signal< Orientation, int, int > & | headerDataChanged () |
virtual Signal & | layoutAboutToBeChanged () |
virtual Signal & | layoutChanged () |
virtual Signal & | modelReset () |
![]() | |
void | addChild (std::unique_ptr< WObject > child) |
Child * | addChild (std::unique_ptr< Child > child) |
std::unique_ptr< WObject > | removeChild (WObject *child) |
std::unique_ptr< Child > | removeChild (Child *child) |
virtual const std::string | id () const |
virtual void | setObjectName (const std::string &name) |
virtual std::string | objectName () const |
void | resetLearnedSlots () |
void | resetLearnedSlot (void(T::*method)()) |
WStatelessSlot * | implementStateless (void(T::*method)()) |
WStatelessSlot * | implementStateless (void(T::*method)(), void(T::*undoMethod)()) |
void | isNotStateless () |
WStatelessSlot * | implementJavaScript (void(T::*method)(), const std::string &jsCode) |
![]() | |
observable () noexcept | |
virtual | ~observable () |
auto | bindSafe (void(C::*method)(Args...)) noexcept |
auto | bindSafe (void(C::*method)(Args...) const) const noexcept |
auto | bindSafe (const Function &function) noexcept |
Private Types | |
using | RowItem = std::vector< std::unique_ptr< Wt::WStandardItem > > |
using | ColItem = Wt::WStandardItem * |
Private Member Functions | |
auto | setStyleClass (int _row, const std::string &_class) -> void |
auto | removeStyleClass (int _row, const std::string &_class) -> void |
auto | getString (const Wt::WModelIndex &_index, int column) -> std::string |
auto | saveToDisk (const Wt::WModelIndex &_index) -> void |
Private Attributes | |
Wt::Signal< Wt::WModelIndex > | m_goneDirty |
bool | m_readOnly = false |
Editable Indicator. | |
ViewMode | m_viewMode = ViewMode::BASIC_LEDGER |
bool | m_doubleLine = false |
std::string | m_accountGuid |
Account GUID. | |
Wt::WDateTime | m_lastDate |
int | m_splitCount |
Accumulators. | |
GCW_NUMERIC | m_balance |
GCW_NUMERIC | m_present |
GCW_NUMERIC | m_future |
GCW_NUMERIC | m_cleared |
GCW_NUMERIC | m_reconciled |
GCW_NUMERIC | m_projected |
Friends | |
class | Eng::Transaction::Manager |
Additional Inherited Members | |
![]() | |
typedef std::map< ItemDataRole, cpp17::any > | DataMap |
![]() | |
typedef void(WObject::* | Method) () |
![]() | |
virtual void | copyData (const WModelIndex &sIndex, const WModelIndex &dIndex) override |
![]() | |
void | reset () |
WModelIndex | createIndex (int row, int column, void *ptr) const |
WModelIndex | createIndex (int row, int column, ::uint64_t id) const |
void | beginInsertColumns (const WModelIndex &parent, int first, int last) |
void | beginInsertRows (const WModelIndex &parent, int first, int last) |
void | beginRemoveColumns (const WModelIndex &parent, int first, int last) |
void | beginRemoveRows (const WModelIndex &parent, int first, int last) |
void | endInsertColumns () |
void | endInsertRows () |
void | endRemoveColumns () |
void | endRemoveRows () |
![]() | |
virtual WStatelessSlot * | getStateless (Method method) |
Account Register Model.
This model is used to present account details to the 'editor register' (the spreadsheet-looking book-like-looking thing that the user posts transactions through.
|
private |
|
private |
GCW::Gui::AccountRegister::Model::Model | ( | ) |
ctor
This constructs the model, empty.
Definition at line 14 of file Model.cpp.
References Wt::asString(), Wt::WModelIndex::column(), Wt::WDateTime::currentDateTime(), Wt::WAbstractItemModel::data(), Wt::WModelIndex::data(), Wt::WAbstractItemModel::dataChanged(), Wt::ItemDataRole::Display, GCW_DATE_DEFAULT_TIME, Wt::WStandardItemModel::itemChanged(), m_lastDate, Wt::WModelIndex::row(), and Wt::WDateTime::setTime().
|
inline |
|
inline |
Definition at line 50 of file Model.h.
References m_doubleLine.
|
inline |
auto GCW::Gui::AccountRegister::Model::getAction | ( | const Wt::WModelIndex & | _index | ) | -> std::string |
Get Action.
Definition at line 255 of file Model.cpp.
References GCW::Gui::AccountRegister::ACTION, and GCW::Gui::AccountRegister::asInt().
auto GCW::Gui::AccountRegister::Model::getBalance | ( | const Wt::WModelIndex & | _index | ) | -> GCW_NUMERIC |
Get Balance (positive or negative)
auto GCW::Gui::AccountRegister::Model::getCredit | ( | const Wt::WModelIndex & | _index | ) | -> GCW_NUMERIC |
Get Credit value.
Definition at line 318 of file Model.cpp.
References GCW::Gui::AccountRegister::asInt(), and GCW::Gui::AccountRegister::CREDIT.
auto GCW::Gui::AccountRegister::Model::getDate | ( | const Wt::WModelIndex & | _index | ) | -> Wt::WDateTime |
Get Date from the index.
This pulls the 'date' column out and returns it as a WDateTime value.
Definition at line 235 of file Model.cpp.
References GCW::Gui::AccountRegister::asInt(), GCW::Gui::AccountRegister::DATE, Wt::WDateTime::fromString(), GCW_DATE_DEFAULT_TIME, GCW_DATE_FORMAT_DISPLAY, and Wt::WDateTime::setTime().
auto GCW::Gui::AccountRegister::Model::getDebit | ( | const Wt::WModelIndex & | _index | ) | -> GCW_NUMERIC |
Get Debit value.
Definition at line 309 of file Model.cpp.
References GCW::Gui::AccountRegister::asInt(), and GCW::Gui::AccountRegister::DEBIT.
auto GCW::Gui::AccountRegister::Model::getDescription | ( | const Wt::WModelIndex & | _index | ) | -> std::string |
Get Description.
Definition at line 263 of file Model.cpp.
References GCW::Gui::AccountRegister::asInt(), and GCW::Gui::AccountRegister::DESCRIPTION.
auto GCW::Gui::AccountRegister::Model::getNumeric | ( | const Wt::WModelIndex & | _index | ) | -> GCW_NUMERIC |
Get numeric value.
This returns the numeric value of the line. This is suitable for querying either the debit or credit column values (and is really intended for internal use). The 'value' is pulled from the Display value of the index and converted to a GCW_NUMERIC value.
Definition at line 296 of file Model.cpp.
References Wt::asString(), Wt::ItemDataRole::Display, GCW_NUMERIC, and Wt::WString::toUTF8().
auto GCW::Gui::AccountRegister::Model::getReconcile | ( | const Wt::WModelIndex & | _index | ) | -> std::string |
Get Reconciliation.
Definition at line 288 of file Model.cpp.
References GCW::Gui::AccountRegister::asInt(), and GCW::Gui::AccountRegister::RECONCILE.
auto GCW::Gui::AccountRegister::Model::getSplitGuid | ( | const Wt::WModelIndex & | _index | ) | -> std::string |
Get GUID from row.
This will retrieve the GUID value from the row.
Definition at line 342 of file Model.cpp.
References GCW::Gui::AccountRegister::asInt(), Wt::asString(), GCW::Gui::AccountRegister::DATE, and Wt::ItemDataRole::User.
auto GCW::Gui::AccountRegister::Model::getSplitGuid | ( | int | _row | ) | -> std::string |
Definition at line 356 of file Model.cpp.
References GCW::Gui::AccountRegister::asInt(), and GCW::Gui::AccountRegister::DATE.
|
private |
Definition at line 221 of file Model.cpp.
References Wt::asString(), and Wt::ItemDataRole::Display.
auto GCW::Gui::AccountRegister::Model::getTransferGuid | ( | const Wt::WModelIndex & | _index | ) | -> std::string |
Get Transfer Account GUID.
Definition at line 279 of file Model.cpp.
References GCW::Dbo::Accounts::byFullName().
auto GCW::Gui::AccountRegister::Model::getTransferText | ( | const Wt::WModelIndex & | _index | ) | -> std::string |
Get Transfer Account Text.
Definition at line 271 of file Model.cpp.
References GCW::Gui::AccountRegister::asInt(), and GCW::Gui::AccountRegister::TRANSFER.
auto GCW::Gui::AccountRegister::Model::getValue | ( | const Wt::WModelIndex & | _index | ) | -> GCW_NUMERIC |
Get Value (positive or negative)
The value that gets stored in the back-end database is either positive for debit, and negative for credit. This function will read-out the debit and credit columns in the register display and figure out if the returned value should be returned positive or negative corrected.
This function always positive for debit, and negative for credit values.
Definition at line 327 of file Model.cpp.
References GCW_NUMERIC.
|
inline |
Definition at line 187 of file Model.h.
References m_goneDirty.
auto GCW::Gui::AccountRegister::Model::isDeletable | ( | const Wt::WModelIndex & | _index | ) | -> bool |
Is Read Only.
This returns .true. if the item can be deleted.
If this transaction split has no guid then it's a new row, and cannot be deleted
If this transaction split is reconciled, then it is considered not deletable
Definition at line 101 of file Model.cpp.
References GCW::Dbo::Splits::byGuid(), and split().
auto GCW::Gui::AccountRegister::Model::isJumpable | ( | const Wt::WModelIndex & | _index | ) | -> bool |
auto GCW::Gui::AccountRegister::Model::isReadOnly | ( | ) | -> bool |
auto GCW::Gui::AccountRegister::Model::isReadOnly | ( | const Wt::WModelIndex & | _index | ) | -> bool |
If this transaction split has no guid then it's a new row, and can be edited
If this transaction split is reconciled, then it is considered not editable.
We have to convert this _index in to the proper split that represents it, and then query that split to see if it is reconciled or not. We use the transaction manager to get this done, as it encapsulates a bunch of different tools for manipulating the data.
auto GCW::Gui::AccountRegister::Model::isReadOnly | ( | int | _row | ) | -> bool |
auto GCW::Gui::AccountRegister::Model::makeRow | ( | const std::string & | _splitGuid | ) | -> RowItem |
|
inline |
|
inline |
Definition at line 172 of file Model.h.
References m_projected.
|
inline |
Definition at line 171 of file Model.h.
References m_reconciled.
auto GCW::Gui::AccountRegister::Model::refreshFromDisk | ( | ) | -> void |
Refresh From Disk.
This procedure reads from the gnucash storage source (either postgres or sqlite) and loads all of the transactions and their associated splits in to the model suitable for editing within an automatic table view.
Before refreshing from disk, the entire contents of the model are cleared, so it is important to make sure anything to be saved from the model is done first.
In order to produce a proper 'register' of items, it is important to load the data from the 'splits' side of the transaction rather than the transaction itself.
Note that when the splits are loaded based on the account ID, they are returned in a std::vector(sorted_by_date) that is sorted based on the transction date. This chosen sort method insures that the running balance can be accurately calculated on the fly, since each item is pulled from the vector in a sorted order, and the running balance is included in the model row. The user can sort the user interface later and still have the line-item-balance remain accurate.
Each item is processed from the vector in sequential order. In this process we grab the contents of the split, and generate a model item row containing all of the column values. Maintain a running balance as we go along to keep the balance reflected within the view. The result is a multi-column row item that is added to the model. This allows the model to be subsequently re-sorted or subset-extracted without affecting the running balances and so forth.
After all the split items are loaded, an additional ~blank~ item is included at the end of the vector, for coding new entries.
poke all the header labels in. Note that some of the labels change depending on the account debit/credit type. We get those from the accountDef.
Definition at line 603 of file Model.cpp.
References GCW::Eng::Transaction::Manager::appendRow(), GCW::Dbo::Splits::byAccount(), GCW::Dbo::Accounts::byGuid(), GCW::Dbo::Accounts::ACCOUNTDEF_S::colAccount, GCW::Dbo::Accounts::ACCOUNTDEF_S::colCr, GCW::Dbo::Accounts::ACCOUNTDEF_S::colDr, Wt::ItemDataRole::Edit, Wt::Editable, GCW_NUMERIC, GCW_RECONCILE_YES, GCW::Dbo::Prefrences::get(), GCW::Dbo::Accounts::s_accountDefs, GCW::Eng::Transaction::Manager::setReadOnly(), GCW::Eng::Transaction::Manager::setSplitItem(), TR, and GCW::Eng::Transaction::Manager::transactionItem().
|
private |
auto GCW::Gui::AccountRegister::Model::saveToDisk | ( | ) | -> void |
Definition at line 213 of file Model.cpp.
References FUNCTION_HEADER.
|
private |
Definition at line 364 of file Model.cpp.
References GCW::Gui::AccountRegister::ACTION, GCW::Gui::AccountRegister::asInt(), GCW::Gui::AccountRegister::CREDIT, GCW::Gui::AccountRegister::DATE, GCW::Gui::AccountRegister::DEBIT, GCW::Gui::AccountRegister::DESCRIPTION, GCW::Eng::Transaction::Manager::loadSplit(), GCW::Eng::Transaction::Manager::newTransaction(), GCW::Gui::AccountRegister::NOTES, GCW::Gui::AccountRegister::RECONCILE, GCW::Eng::Transaction::Manager::setAction(), GCW::Eng::Transaction::Manager::setDate(), GCW::Eng::Transaction::Manager::setDescription(), GCW::Eng::Transaction::Manager::setNotes(), GCW::Eng::Transaction::Manager::setReconcile(), GCW::Eng::Transaction::Manager::setTransferGuid(), GCW::Eng::Transaction::Manager::setValue(), and GCW::Gui::AccountRegister::TRANSFER.
auto GCW::Gui::AccountRegister::Model::setAccountGuid | ( | const std::string & | _accountGuid | ) | -> void |
auto GCW::Gui::AccountRegister::Model::setData | ( | const Wt::WModelIndex & | _index, |
const Wt::cpp17::any & | _value, | ||
Wt::ItemDataRole | _role | ||
) | -> bool |
Definition at line 466 of file Model.cpp.
References Wt::asString(), BREAKFOOTER, BREAKHEADER, Wt::ItemDataRole::Edit, and Wt::WAbstractItemModel::setData().
auto GCW::Gui::AccountRegister::Model::setDoubleLine | ( | bool | _doubleLine | ) | -> void |
|
inline |
Definition at line 83 of file Model.h.
References m_readOnly.
|
private |
auto GCW::Gui::AccountRegister::Model::setViewMode | ( | ViewMode | _viewMode | ) | -> void |
auto GCW::Gui::AccountRegister::Model::splitCount | ( | ) | -> int |
Split Count.
This is ~slightly~ different than the rowCount() since rowCount will return the number of rows in the model, and splitCount will return the number of splits used to build the model.
auto GCW::Gui::AccountRegister::Model::suggestionsFromColumn | ( | int | _column | ) | const -> std::set< std::string > |
Column Suggestions.
This produces a unique-set of items that represent all the text-values for that particular column. This is used to produce a suggestion-box for the register.
Definition at line 820 of file Model.cpp.
References Wt::asString(), and Wt::WString::toUTF8().
|
inline |
Definition at line 47 of file Model.h.
References m_viewMode.
|
friend |
|
private |
|
private |
|
private |
|
private |
Definition at line 227 of file Model.h.
Referenced by doubleLine().
|
private |
|
private |
Definition at line 212 of file Model.h.
Referenced by goneDirty().
|
private |
|
private |
|
private |
Definition at line 271 of file Model.h.
Referenced by projected().
|
private |
Editable Indicator.
The model can be either R/W (read-write) or R/O (read-only).
Definition at line 224 of file Model.h.
Referenced by setReadOnly().
|
private |
Definition at line 270 of file Model.h.
Referenced by reconciled().
|
private |
Accumulators.
balance balance limit balance (Period) balance usd cleared cleared usd fiture minimum future minimum usa last num last reconcile date opening balance present present usd reconciled reconciled usd total total period total usd
|
private |
Definition at line 226 of file Model.h.
Referenced by viewMode().