GnuCashew ~ Web Application compatible with GnuCash sql data files.
GCW
Loading...
Searching...
No Matches
TransactionDetailWidget.cpp
Go to the documentation of this file.
1#line 2 "src/Gui/TransactionDetailWidget.cpp"
2
3#include <Wt/WDateEdit.h>
4#include <Wt/WPushButton.h>
5#include <Wt/WSuggestionPopup.h>
6#include <Wt/WText.h>
7#include <Wt/WTemplate.h>
8#include <Wt/WTableView.h>
9#include <Wt/WTheme.h>
10#include <Wt/WVBoxLayout.h>
11#include <Wt/WHBoxLayout.h>
12#include <Wt/WMessageBox.h>
13
14#include "../define.h"
15#include "../Eng/TransactionManager.h"
17
18/* * * * * * * * * * * * * * * * * * * * * * * * * * */
19/* * * * * * * * * * * * * * * * * * * * * * * * * * */
20
21
23TransactionDetailWidget( const std::string & _tx_guid )
24: Wt::WContainerWidget(),
25 m_tx_guid( _tx_guid )
26{
27
28 auto templt = addNew< Wt::WTemplate >( TR("gcw.AccountRegister.details.contents") );
29
31 mtxt_currency = templt-> bindNew< Wt::WText >( "currency_guid" );
35 mtxt_description = templt-> bindNew< Wt::WText >( "description" );
36 m_splitsTable = templt-> bindNew< Wt::WTable >( "splitsTable" );
37
38} // endTransactionDetailWidget()
39
40
41
42auto
44setTxGuid( const std::string & _tx_guid )-> void
45{
46
47} // endsetTxGuid( const std::string & _tx_guid )-> void
48
49
50
51auto
53setSplitGuid( const std::string & _guid )-> void
54{
55 auto transMan = GCW::Eng::Transaction::Manager();
56 transMan.loadSplit( _guid );
57 mtxt_guid -> setText( transMan.transactionItem()-> guid() );
58 mtxt_currency -> setText( transMan.transactionItem()-> currency_guid() );
59 mtxt_num -> setText( transMan.transactionItem()-> num() );
60 mtxt_post_date -> setText( transMan.transactionItem()-> post_date() );
61 mtxt_enter_date -> setText( transMan.transactionItem()-> enter_date() );
62 mtxt_description -> setText( transMan.transactionItem()-> description() );
63
64 m_splitsTable-> clear();
65 int row = 0;
66 for( auto splitItem : transMan.splits() )
67 {
68 m_splitsTable-> elementAt( row, 0 )-> addNew< GCW::Gui::TransactionDetailWidget::SplitWidget >( splitItem-> guid() );
69 row++;
70 }
71
72} // endsetSplitGuid( const std::string & _guid )-> void
73
74
75auto
77saveData()-> void
78{
79 // nothing to do, not saving yet
80}
81
82
84SplitWidget( const std::string & _guid )
85: Wt::WContainerWidget(),
86 m_guid( _guid )
87{
88
90
91 auto templt = addNew< Wt::WTemplate >( TR("gcw.AccountRegister.details.contents.split") );
92
94 {
95 std::string retVal = splitItem-> reconcile_state();
96
97 if( splitItem-> reconcile_state() == "y" )
98 retVal += " (reconciled)";
99
100 if( splitItem-> reconcile_state() == "n" )
101 retVal += " (not reconciled)";
102
103 if( splitItem-> reconcile_state() == "c" )
104 retVal += " (cleared)";
105
106 retVal += " " + splitItem-> reconcile_date();
107
108 return retVal;
109
110 };
111
112 templt-> bindString( "guid", splitItem-> guid() );
113 templt-> bindString( "tx_guid", splitItem-> tx_guid() );
114 templt-> bindString( "account", splitItem-> account_guid() + "<br />" + GCW::Dbo::Accounts::fullName( splitItem-> account_guid() ) );
115 templt-> bindString( "memo", splitItem-> memo() );
116 templt-> bindString( "action", splitItem-> action() );
117 templt-> bindString( "reconcile", _reconcile_state() );
118 templt-> bindString( "value", splitItem-> valueAsString() );
119
120} // endTransactionDetailWidget()
121
122
auto saveData() -> void
Save the data to the backend.
auto setSplitGuid(const std::string &_guid) -> void
Set Split GUID.
auto setTxGuid(const std::string &_guid) -> void
Set Transaction GUID.
TransactionDetailWidget(const std::string &_tx_guid="")
Empty ctor.
Widget * addNew(Args &&...args)
#define TR(X)
Definition define.h:17
auto fullName(const std::string &_guid) -> std::string
Account Fullname via GUID.
auto load(const std::string &_splitGuid) -> Item::Ptr
Load a single split.
Definition Splits.cpp:14