|
GnuCashew ~ Web Application compatible with GnuCash sql data files.
GCW
|
#include <TransactionManager.h>
Public Types | |
| using | RowItem = std::vector< std::unique_ptr< Wt::WStandardItem > > |
| using | TxItem = GCW::Dbo::Transactions::Item::Ptr |
| using | SpItem = GCW::Dbo::Splits::Item::Ptr |
Public Member Functions | |
| Manager () | |
| Manager (Gui::AccountRegister::Model *_model) | |
| auto | model () const -> Gui::AccountRegister::Model * |
| auto | loadTransaction (const std::string &_transactionGuid) -> void |
| Set Transaction. | |
| auto | deleteTransaction () -> bool |
| Delete Transaction. | |
| auto | setSplitItem (GCW::Dbo::Splits::Item::Ptr _splitItem) -> void |
| auto | loadSplit (const std::string &_splitGuid) -> void |
| Set Split. | |
| auto | sortSplits () -> void |
| Sort Splits. | |
| auto | isBalanced () -> bool |
| Is Transaction Balanced. | |
| auto | balanceValue () -> GCW_NUMERIC |
| Balance Value. | |
| auto | newTransaction (const std::string &_accountGuid1, const std::string &_accountGuid2, const Wt::WDate &_date=Wt::WDate::currentDate(), GCW_NUMERIC _value=GCW_NUMERIC(0), const std::string &_description="") -> void |
| New Transaction. | |
| auto | transactionItem () const -> GCW::Dbo::Transactions::Item::Ptr |
| Transaction Item. | |
| auto | prefrenceItem () const -> const GCW::Dbo::Prefrences::Item & |
| auto | splits () const -> GCW::Dbo::Splits::Item::Vector |
| Splits Vector. | |
| auto | otherSplits () const -> GCW::Dbo::Splits::Item::Vector |
| auto | otherGuid () const -> std::string |
| Other GUID. | |
| auto | getDate () const -> Wt::WDateTime |
| Set Date. | |
| auto | getDateAsString () const -> Wt::WString |
| auto | setDate (const Wt::WDateTime &_value) -> void |
| auto | setDate (const Wt::WDate &_value) -> void |
| auto | setAction (const std::string &_value) -> void |
| Set Action. | |
| auto | getDescription () const -> std::string |
| Set Description. | |
| auto | setDescription (const std::string &_value) -> void |
| auto | setDescription (const Wt::WString &_value) -> void |
| auto | getNum () const -> std::string |
| Set Num. | |
| auto | setNum (const std::string &_value) -> void |
| auto | setNum (const Wt::WString &_value) -> void |
| auto | setTransferGuid (const std::string &_value) -> void |
| Set Transfer GUID. | |
| auto | setReconcile (const std::string &_value) -> void |
| auto | getValue () const -> GCW_NUMERIC |
| auto | getValueAsString () const -> std::string |
| auto | setValue (GCW_NUMERIC _value) -> void |
| auto | setValue (const std::string &_acctGuid, GCW_NUMERIC _value) -> void |
| auto | setNotes (const std::string &_acctGuid, const std::string &_value) -> void |
| auto | split (const std::string &_splitGuid) const -> GCW::Dbo::Splits::Item::Ptr |
| auto | forAccountSplit (const std::string &_accountGuid) const -> GCW::Dbo::Splits::Item::Ptr |
| Load Split for Account. | |
| auto | thisSplit () const -> GCW::Dbo::Splits::Item::Ptr |
| auto | thatSplit () const -> GCW::Dbo::Splits::Item::Ptr |
| auto | fromSplit () const -> GCW::Dbo::Splits::Item::Ptr |
| auto | toSplit () const -> GCW::Dbo::Splits::Item::Ptr |
| auto | getFromAccount () const -> std::string |
| auto | getToAccount () const -> std::string |
| auto | setReadOnly (bool _value) -> void |
| auto | appendRow (bool _editable) -> void |
| auto | appendEmptyRow (bool _editable) -> void |
| auto | insertDoubleLine (int _row) -> void |
Private Member Functions | |
| auto | highlightNegativeBalance (RowItem &_row) const -> void |
| auto | flags (bool _editable) const -> Wt::WFlags< Wt::ItemFlag > |
| auto | createText (const std::string &_text) const -> std::unique_ptr< Wt::WStandardItem > |
| auto | createBlank () const -> std::unique_ptr< Wt::WStandardItem > |
| auto | createEmpty () const -> std::unique_ptr< Wt::WStandardItem > |
| auto | createDate (const TxItem &_txItem, bool _editable) const -> std::unique_ptr< Wt::WStandardItem > |
| auto | createNum (const TxItem &_txItem, bool _editable) const -> std::unique_ptr< Wt::WStandardItem > |
| auto | createNum (const SpItem &_spItem, bool _editable) const -> std::unique_ptr< Wt::WStandardItem > |
| auto | createDescription (const TxItem &_txItem, bool _editable) const -> std::unique_ptr< Wt::WStandardItem > |
| auto | createDescription (const SpItem &_spItem, bool _editable) const -> std::unique_ptr< Wt::WStandardItem > |
| auto | createAccount (const SpItem &_spItem, bool _editable) const -> std::unique_ptr< Wt::WStandardItem > |
| auto | createReconcile (const SpItem &_spItem, bool _editable) const -> std::unique_ptr< Wt::WStandardItem > |
| auto | createDebit (const SpItem &_spItem, bool _editable) const -> std::unique_ptr< Wt::WStandardItem > |
| auto | createCredit (const SpItem &_spItem, bool _editable) const -> std::unique_ptr< Wt::WStandardItem > |
| auto | createBalance () const -> std::unique_ptr< Wt::WStandardItem > |
| auto | appendBasicLedger (bool _editable) const -> void |
| auto | appendAutosplitLedger (bool _editable) const -> void |
| auto | appendTransactionJournal (bool _editable) const -> void |
| auto | appendGeneralJournal (bool _editable) const -> void |
Private Attributes | |
| Gui::AccountRegister::Model * | m_model = nullptr |
| Wt::WModelIndex | m_index |
| std::string | m_splitGuid |
| GCW::Dbo::Transactions::Item::Ptr | m_transactionItem |
| GCW::Dbo::Prefrences::Item | m_prefrenceItem |
| GCW::Dbo::Splits::Item::Vector | m_splits |
This is a convenience class for grouping all the transaction manipulation tasks in to one place. It allows new transactions to be created, and takes care of insuring that the transaction is always in balance, and always contains the requisite debits and credits to insure a properly balanced transaction.
The Transaction Manager is a 'friend' class to the AccountRegisterModel. This allows the manager to poke directly in to the model and manipulate it.
Definition at line 36 of file TransactionManager.h.
| using GCW::Eng::Transaction::Manager::RowItem = std::vector< std::unique_ptr< Wt::WStandardItem > > |
Definition at line 40 of file TransactionManager.h.
Definition at line 42 of file TransactionManager.h.
Definition at line 41 of file TransactionManager.h.
| GCW::Eng::Transaction::Manager::Manager | ( | ) |
Definition at line 7 of file TransactionManager.cpp.
| GCW::Eng::Transaction::Manager::Manager | ( | Gui::AccountRegister::Model * | _model | ) |
Definition at line 14 of file TransactionManager.cpp.
|
private |
Definition at line 940 of file TransactionManager.cpp.
|
private |
Definition at line 909 of file TransactionManager.cpp.
References GCW_RECONCILE_NO.
| auto GCW::Eng::Transaction::Manager::appendEmptyRow | ( | bool | _editable | ) | -> void |
Definition at line 1070 of file TransactionManager.cpp.
Referenced by GCW::Gui::AccountRegister::Model::refreshFromDisk().
|
private |
Definition at line 1000 of file TransactionManager.cpp.
| auto GCW::Eng::Transaction::Manager::appendRow | ( | bool | _editable | ) | -> void |
Definition at line 1008 of file TransactionManager.cpp.
References GCW::Gui::AccountRegister::AUTOSPLIT_LEDGER, GCW::Gui::AccountRegister::BASIC_LEDGER, GCW::Gui::AccountRegister::GENERAL_JOURNAL, and GCW::Gui::AccountRegister::TRANSACTION_JOURNAL.
Referenced by GCW::Gui::AccountRegister::Model::refreshFromDisk().
|
private |
Definition at line 946 of file TransactionManager.cpp.
References GCW_RECONCILE_NO.
| auto GCW::Eng::Transaction::Manager::balanceValue | ( | ) | -> GCW_NUMERIC |
Balance Value.
This checks the splits on the transaction and returns the 'balance value' which should be zero when the transaction is in balance.
see; gnucash/libgnucash/engine/Transaction.cpp:1030
|
private |
Definition at line 742 of file TransactionManager.cpp.
References Wt::WString::arg(), GCW::Dbo::Accounts::byGuid(), GCW::Dbo::Accounts::fullName(), Wt::WString::toUTF8(), and TR.
|
private |
Definition at line 867 of file TransactionManager.cpp.
References GCW::Cfg::decimal_format().
|
private |
Definition at line 463 of file TransactionManager.cpp.
|
private |
Definition at line 841 of file TransactionManager.cpp.
|
private |
Definition at line 489 of file TransactionManager.cpp.
References Wt::WDate::currentDate(), Wt::ItemDataRole::Edit, GCW_DATE_DEFAULT_TIME, and Wt::ItemDataRole::User.
|
private |
Definition at line 818 of file TransactionManager.cpp.
|
private |
Definition at line 612 of file TransactionManager.cpp.
|
private |
Definition at line 591 of file TransactionManager.cpp.
|
private |
Definition at line 476 of file TransactionManager.cpp.
|
private |
Definition at line 570 of file TransactionManager.cpp.
|
private |
Definition at line 549 of file TransactionManager.cpp.
|
private |
Definition at line 801 of file TransactionManager.cpp.
|
private |
Definition at line 450 of file TransactionManager.cpp.
| auto GCW::Eng::Transaction::Manager::deleteTransaction | ( | ) | -> bool |
Delete Transaction.
This insures all splits and any other data associated with the transaction is properly removed.
Definition at line 110 of file TransactionManager.cpp.
References GCW::app().
|
private |
Definition at line 435 of file TransactionManager.cpp.
References Wt::DeferredToolTip, Wt::Editable, and Wt::Selectable.
| auto GCW::Eng::Transaction::Manager::forAccountSplit | ( | const std::string & | _accountGuid | ) | const -> GCW::Dbo::Splits::Item::Ptr |
Load Split for Account.
When we know the account guid, this will fetch the associated split
Definition at line 248 of file TransactionManager.cpp.
References split().
| auto GCW::Eng::Transaction::Manager::fromSplit | ( | ) | const -> GCW::Dbo::Splits::Item::Ptr |
Definition at line 199 of file TransactionManager.cpp.
References split().
| auto GCW::Eng::Transaction::Manager::getDate | ( | ) | const -> Wt::WDateTime |
Set Date.
This sets the date on the Transaction of the element.
Definition at line 262 of file TransactionManager.cpp.
| auto GCW::Eng::Transaction::Manager::getDateAsString | ( | ) | const -> Wt::WString |
Definition at line 270 of file TransactionManager.cpp.
References GCW_DATE_FORMAT_DISPLAY.
| auto GCW::Eng::Transaction::Manager::getDescription | ( | ) | const -> std::string |
Set Description.
This sets the description on the Transaction of the element.
Definition at line 307 of file TransactionManager.cpp.
| auto GCW::Eng::Transaction::Manager::getFromAccount | ( | ) | const -> std::string |
Definition at line 225 of file TransactionManager.cpp.
References GCW::Dbo::Accounts::fullName(), and TR8.
| auto GCW::Eng::Transaction::Manager::getNum | ( | ) | const -> std::string |
Set Num.
On the Transaction, the 'num' is the action field, on the splits it is the action value. So, in transaction it's called 'num' and in the splits it's called 'action'.
Definition at line 332 of file TransactionManager.cpp.
| auto GCW::Eng::Transaction::Manager::getToAccount | ( | ) | const -> std::string |
Definition at line 236 of file TransactionManager.cpp.
References GCW::Dbo::Accounts::fullName(), and TR8.
| auto GCW::Eng::Transaction::Manager::getValue | ( | ) | const -> GCW_NUMERIC |
Definition at line 375 of file TransactionManager.cpp.
| auto GCW::Eng::Transaction::Manager::getValueAsString | ( | ) | const -> std::string |
Definition at line 383 of file TransactionManager.cpp.
|
private |
Definition at line 884 of file TransactionManager.cpp.
References GCW::Dbo::Prefrences::NEGVAL_EXTRA, and GCW::Dbo::Prefrences::NORMAL.
| auto GCW::Eng::Transaction::Manager::insertDoubleLine | ( | int | _row | ) | -> void |
Definition at line 1082 of file TransactionManager.cpp.
Referenced by GCW::Gui::AccountRegister::Model::applyDoubleLine().
| auto GCW::Eng::Transaction::Manager::isBalanced | ( | ) | -> bool |
Is Transaction Balanced.
This checks the transaction and indicates if it is in balance or not.
see; gnucash/libgnucash/engine/Transaction.cpp:1030
| auto GCW::Eng::Transaction::Manager::loadSplit | ( | const std::string & | _splitGuid | ) | -> void |
Set Split.
Set transaction based on any one of the splits.
This will load the split, then load the transaction for that split, causing all the other splits to load.
Definition at line 135 of file TransactionManager.cpp.
References GCW::Dbo::Splits::load().
Referenced by GCW::Gui::AccountRegister::Model::saveToDisk().
| auto GCW::Eng::Transaction::Manager::loadTransaction | ( | const std::string & | _transactionGuid | ) | -> void |
Set Transaction.
Set transaction based on the transaction Guid. This will load the transaction as well as all the splits associated with it.
Definition at line 94 of file TransactionManager.cpp.
References GCW::Dbo::Splits::byTransaction(), and GCW::Dbo::Transactions::load().
|
inline |
Definition at line 47 of file TransactionManager.h.
References m_model.
| auto GCW::Eng::Transaction::Manager::newTransaction | ( | const std::string & | _accountGuid1, |
| const std::string & | _accountGuid2, | ||
| const Wt::WDate & | _date = Wt::WDate::currentDate(), |
||
| GCW_NUMERIC | _value = GCW_NUMERIC(0), |
||
| const std::string & | _description = "" |
||
| ) | -> void |
New Transaction.
This will create a new Transaction for an account within the system fully populated with at least two splits.
The process begins by loading up the two accounts.
this transaction posting shows that .value. as well as .quantity. are set at the same time. If .quantity. is not set, then when re-opening the sql file in gnucash native causes the gnucash to take a very long time to load. This only happens once, and upon examining the database afterwords, all the splits have the same .value. set to .quantity. So, some sort of massive update is happening there on file-open. Therefore, we will set .quantity. along with .value. Doing so seems to mitigate the long/slow load time.
Definition at line 23 of file TransactionManager.cpp.
References GCW::Dbo::Splits::add(), GCW::Dbo::Transactions::add(), GCW::app(), Wt::WDate::currentDate(), GCW_DEFAULT_DATE, GCW_RECONCILE_NO, GCW::Dbo::Accounts::load(), and GCW::Core::newGuid().
Referenced by GCW::Gui::BillPay::PaymentWidget::saveData(), and GCW::Gui::AccountRegister::Model::saveToDisk().
| auto GCW::Eng::Transaction::Manager::otherGuid | ( | ) | const -> std::string |
Other GUID.
When there are only two splits, this will return the guid of the split item that does not match the guid provided.
Definition at line 159 of file TransactionManager.cpp.
| auto GCW::Eng::Transaction::Manager::otherSplits | ( | ) | const -> GCW::Dbo::Splits::Item::Vector |
Definition at line 420 of file TransactionManager.cpp.
References GCW::Dbo::Splits::bySplitExcept().
|
inline |
Definition at line 119 of file TransactionManager.h.
References m_prefrenceItem.
| auto GCW::Eng::Transaction::Manager::setAction | ( | const std::string & | _value | ) | -> void |
Set Action.
This sets the Action on the split. The 'action' is stored in the Split item and this function will apply the value to both sides of the split.
Definition at line 298 of file TransactionManager.cpp.
References GCW::app().
Referenced by GCW::Gui::AccountRegister::Model::saveToDisk().
| auto GCW::Eng::Transaction::Manager::setDate | ( | const Wt::WDate & | _value | ) | -> void |
Definition at line 287 of file TransactionManager.cpp.
References GCW::app().
| auto GCW::Eng::Transaction::Manager::setDate | ( | const Wt::WDateTime & | _value | ) | -> void |
Definition at line 278 of file TransactionManager.cpp.
References GCW::app().
Referenced by GCW::Gui::BillPay::PaymentWidget::saveData(), and GCW::Gui::AccountRegister::Model::saveToDisk().
| auto GCW::Eng::Transaction::Manager::setDescription | ( | const std::string & | _value | ) | -> void |
Definition at line 315 of file TransactionManager.cpp.
References GCW::app().
Referenced by GCW::Gui::BillPay::PaymentWidget::saveData(), and GCW::Gui::AccountRegister::Model::saveToDisk().
| auto GCW::Eng::Transaction::Manager::setDescription | ( | const Wt::WString & | _value | ) | -> void |
Definition at line 324 of file TransactionManager.cpp.
| auto GCW::Eng::Transaction::Manager::setNotes | ( | const std::string & | _acctGuid, |
| const std::string & | _value | ||
| ) | -> void |
Definition at line 410 of file TransactionManager.cpp.
References GCW::app().
Referenced by GCW::Gui::BillPay::PaymentWidget::saveData(), and GCW::Gui::AccountRegister::Model::saveToDisk().
| auto GCW::Eng::Transaction::Manager::setNum | ( | const std::string & | _value | ) | -> void |
Definition at line 340 of file TransactionManager.cpp.
References GCW::app().
Referenced by GCW::Gui::BillPay::PaymentWidget::saveData().
| auto GCW::Eng::Transaction::Manager::setNum | ( | const Wt::WString & | _value | ) | -> void |
Definition at line 349 of file TransactionManager.cpp.
| auto GCW::Eng::Transaction::Manager::setReadOnly | ( | bool | _value | ) | -> void |
Definition at line 428 of file TransactionManager.cpp.
| auto GCW::Eng::Transaction::Manager::setReconcile | ( | const std::string & | _value | ) | -> void |
Definition at line 366 of file TransactionManager.cpp.
References GCW::app().
Referenced by GCW::Gui::AccountRegister::Model::saveToDisk().
| auto GCW::Eng::Transaction::Manager::setSplitItem | ( | GCW::Dbo::Splits::Item::Ptr | _splitItem | ) | -> void |
Definition at line 124 of file TransactionManager.cpp.
Referenced by GCW::Gui::AccountRegister::Model::refreshFromDisk().
| auto GCW::Eng::Transaction::Manager::setTransferGuid | ( | const std::string & | _value | ) | -> void |
Set Transfer GUID.
This sets the (other) split (identified by guid) to the account given.
Definition at line 357 of file TransactionManager.cpp.
References GCW::app().
Referenced by GCW::Gui::AccountRegister::Model::saveToDisk().
| auto GCW::Eng::Transaction::Manager::setValue | ( | const std::string & | _acctGuid, |
| GCW_NUMERIC | _value | ||
| ) | -> void |
Definition at line 401 of file TransactionManager.cpp.
References GCW::app().
| auto GCW::Eng::Transaction::Manager::setValue | ( | GCW_NUMERIC | _value | ) | -> void |
Definition at line 391 of file TransactionManager.cpp.
Referenced by GCW::Gui::BillPay::PaymentWidget::saveData(), and GCW::Gui::AccountRegister::Model::saveToDisk().
| auto GCW::Eng::Transaction::Manager::sortSplits | ( | ) | -> void |
Sort Splits.
Sorts first Debits, then Credits
| auto GCW::Eng::Transaction::Manager::split | ( | const std::string & | _splitGuid | ) | const -> GCW::Dbo::Splits::Item::Ptr |
Definition at line 171 of file TransactionManager.cpp.
|
inline |
Splits Vector.
This returns the splits vector
Definition at line 126 of file TransactionManager.h.
References m_splits.
| auto GCW::Eng::Transaction::Manager::thatSplit | ( | ) | const -> GCW::Dbo::Splits::Item::Ptr |
Definition at line 191 of file TransactionManager.cpp.
References split().
| auto GCW::Eng::Transaction::Manager::thisSplit | ( | ) | const -> GCW::Dbo::Splits::Item::Ptr |
Definition at line 183 of file TransactionManager.cpp.
References split().
| auto GCW::Eng::Transaction::Manager::toSplit | ( | ) | const -> GCW::Dbo::Splits::Item::Ptr |
Definition at line 213 of file TransactionManager.cpp.
References split().
|
inline |
Transaction Item.
This returns the transaction pointer object
Definition at line 118 of file TransactionManager.h.
References m_transactionItem.
Referenced by GCW::Gui::AccountRegister::Model::refreshFromDisk().
|
private |
Definition at line 264 of file TransactionManager.h.
|
private |
Definition at line 263 of file TransactionManager.h.
Referenced by model().
|
private |
Definition at line 267 of file TransactionManager.h.
Referenced by prefrenceItem().
|
private |
Definition at line 265 of file TransactionManager.h.
|
private |
Definition at line 268 of file TransactionManager.h.
Referenced by splits().
|
private |
Definition at line 266 of file TransactionManager.h.
Referenced by transactionItem().