1#line 2 "src/Gui/MainWidget.cpp"
6#include <Wt/WComboBox.h>
7#include <Wt/WPushButton.h>
8#include <Wt/WVBoxLayout.h>
9#include <Wt/Json/Serializer.h>
12#include "../GnuCashew.h"
13#include "../Eng/TransactionManager.h"
37 auto lw =
setLayout( std::make_unique< Wt::WVBoxLayout >() );
63 link.setTarget( Wt::LinkTarget::NewWindow );
64 navBar()-> setResponsive(
true );
65 navBar()-> addStyleClass(
"navbar-light bg-light" );
66 navBar()-> setTitle(
"GCW", link );
72 auto w_ = std::make_unique< GCW::Gui::MainMenu >(
this );
73 m_mainMenu = w_.get();
74 navBar()-> addMenu( std::move( w_ ) );
80 navBar()-> addWidget( std::make_unique< LanguagePicker >(), Wt::AlignmentFlag::Right );
85 toolBar()-> addButton( std::make_unique< PushButton >(
TR(
"gcw.MainWidget.tb.save" ) ) );
86 toolBar()-> addButton( std::make_unique< PushButton >(
TR(
"gcw.MainWidget.tb.close" ) ) );
87 toolBar()-> addButton( std::make_unique< PushButton >(
TR(
"gcw.MainWidget.tb.newInvoice" ) ) );
88 toolBar()-> addButton( std::make_unique< PushButton >(
TR(
"gcw.MainWidget.tb.open" ) ) );
91 auto b = std::make_unique< PushButton >(
TR(
"gcw.MainWidget.tb.edit" ) );
93 toolBar()-> addButton( std::move(b) );
94 e-> clicked().connect( [=](){ openSelectedAccount(); });
97 toolBar()-> addButton( std::make_unique< PushButton >(
TR(
"gcw.MainWidget.tb.new" ) ) );
98 toolBar()-> addButton( std::make_unique< PushButton >(
TR(
"gcw.MainWidget.tb.delete" ) ) );
102 auto b = std::make_unique< PushButton >(
"devtest" );
104 toolBar()-> addButton( std::move(b) );
105 e-> clicked().connect( [=](){ test(); });
109 statusBar()-> addNew< Wt::WText >(
"status bar" );
117 if( !
GCW::app()-> gnucashew_session().isOpen() )
120 auto dialog = addChild( std::make_unique< Wt::WDialog >(
TR(
"gcw.PropertiesWidget.titleBar" ) ) );
121 dialog-> rejectWhenEscapePressed(
true );
122 dialog-> contents()-> addNew< GCW::Gui::FilePropertiesWidget >();
125 finished().connect( [=]()
136 auto templt = std::make_unique< Wt::WTemplate >(
TR(
"gcw.AboutWidget.about" ) );
137 templt-> bindString(
"version",
"none" );
138 templt-> bindString(
"buildid",
"none" );
139 templt-> bindString(
"finance",
"none (yet)" );
141 auto dialog = addChild( std::make_unique< Wt::WDialog >(
TR(
"gcw.AboutWidget.titleBar" ) ) );
142 dialog-> rejectWhenEscapePressed(
true );
143 dialog-> contents()-> addWidget( std::move( templt ) );
146 finished().connect( [=]()
157 centralWidget()-> activateAccountsTreeView();
158 centralWidget()-> accountsTreeView()-> editSelectedAccount();
166 std::cout << __FILE__ <<
":" << __LINE__ <<
" " << std::endl;
174 std::cout << __FILE__ <<
":" << __LINE__ <<
" " << std::endl;
182 std::cout << __FILE__ <<
":" << __LINE__ <<
" " << std::endl;
190 if(
auto accountRegister = centralWidget()-> currentAccountRegister() )
192 auto doubleLine = m_mainMenu-> menuItem(
TR(
"gcw.MainWidget.mu.view.doubleline" ) );
194 accountRegister-> setDoubleLine( doubleLine-> isChecked() );
201auto randomNumber(
int _min,
int _max )->
int
203 static std::random_device rd;
204 static std::mt19937 gen( rd() );
206 std::uniform_int_distribution<> dist( _min, _max );
208 auto retVal = dist( gen );
215test_tableview()->
void
217 auto model = std::make_shared< Wt::WStandardItemModel >();
218 for(
int row = 0; row< 3; row++ )
220 std::vector< std::unique_ptr< Wt::WStandardItem > > rowset;
221 for(
int col = 0; col< 3; col++ )
223 auto item = std::make_unique< Wt::WStandardItem >(
Wt::WString(
"row{1} col{2}").arg( row ).arg( col) );
224 rowset.push_back( std::move( item ) );
227 model-> appendRow( std::move( rowset ) );
230 auto tableView = std::make_unique< Wt::WTableView >();
231 tableView-> setSelectionBehavior ( Wt::SelectionBehavior::Items );
234 tableView-> setSelectionMode ( Wt::SelectionMode::Extended );
235 tableView-> setColumnResizeEnabled (
false );
236 tableView-> setAlternatingRowColors (
true );
237 tableView-> setModel ( model );
239 auto pbgo = std::make_unique< Wt::WPushButton >(
"go" );
241 clicked().connect( [=]()
243 std::cout << __FILE__ <<
":" << __LINE__ <<
" " << std::endl;
246 std::vector< std::unique_ptr< Wt::WStandardItem > > rowset;
247 for(
int col = 0; col< 3; col++ )
249 auto item = std::make_unique< Wt::WStandardItem >(
Wt::WString(
"row{1} col{2}").arg( row ).arg( col) );
250 rowset.push_back( std::move( item ) );
253 model-> insertRow( 2, std::move( rowset ) );
259 dialog.contents()-> addWidget( std::move( pbgo ) );
260 dialog.contents()-> addWidget( std::move( tableView ) );
261 dialog.rejectWhenEscapePressed(
true );
262 dialog.setResizable(
true );
263 dialog.setMinimumSize( 600, 300 );
264 dialog.setClosable(
true );
276load_random_transactions()
278 std::map< std::string, std::vector< std::string > > expenses = {
279 {
"Expenses:Medical Expenses",
281 "Copay for doctor visit",
282 "Prescription refill – CVS",
283 "Dental cleaning – Dr. Smith",
284 "Urgent care visit – weekend",
285 "Eye exam – optometrist",
286 "Physical therapy session",
287 "Lab tests – Quest Diagnostics",
288 "Over-the-counter medication",
289 "Hospital parking fee",
290 "Flu shot – Walgreens"
292 {
"Expenses:Laundry/Dry Cleaning",
294 "Dry cleaning suit – Cleaners Plus",
295 "Wash & fold service",
296 "Shirt pressing – Express Cleaners",
297 "Comforter dry cleaned",
298 "Stain removal – silk blouse",
299 "Laundry card refill",
300 "Pickup & delivery laundry",
302 "Curtain dry cleaning",
303 "Weekly laundry service"
305 {
"Expenses:Groceries",
307 "Weekly grocery run – Walmart",
308 "Produce market – fresh veggies",
309 "Milk and bread – local store",
310 "Bulk items – Costco",
311 "Organic produce – Whole Foods",
312 "Meat & seafood purchase",
313 "Baking supplies – holiday",
314 "Frozen goods – Aldi",
315 "Snacks and beverages",
316 "Pet food – grocery aisle"
320 "Monthly cable bill – Spectrum",
321 "Sports channel add-on",
322 "Premium movie package",
324 "Service technician visit",
326 "Internet & cable bundle",
327 "Pay-per-view boxing event",
328 "Channel upgrade request",
329 "Equipment rental fee"
331 {
"Expenses:Taxes:Other Tax",
333 "Local occupancy tax",
334 "Vehicle registration tax",
336 "Parking permit tax",
337 "Short-term rental tax",
338 "City environmental fee",
339 "Import duty – online order",
340 "Special assessment tax",
341 "Utility usage surcharge",
344 {
"Expenses:Computer",
346 "New laptop purchase",
347 "External hard drive – backup",
348 "Software subscription – Adobe",
349 "Keyboard & mouse combo",
350 "Replacement charger",
352 "Anti-virus renewal",
353 "Laptop repair service",
354 "Cloud storage subscription",
355 "Graphics card upgrade"
359 "Monthly mobile bill – Verizon",
361 "Data overage charge",
362 "International calling plan",
363 "Screen protector purchase",
364 "Device insurance premium",
366 "SIM card replacement",
367 "Voicemail-to-text add-on",
368 "Mobile hotspot charge"
372 "Textbook purchase – college",
373 "E-book download – Kindle",
374 "Magazine subscription",
375 "Used books – thrift store",
376 "Study guide – exam prep",
377 "Children’s storybook",
378 "Hardcover bestseller",
380 "Audio book subscription",
383 {
"Expenses:Insurance:Health Insurance",
385 "Monthly premium – Blue Cross",
386 "Policy renewal fee",
387 "Dependent coverage add-on",
389 "Out-of-network reimbursement",
390 "Health plan deductible payment",
391 "Policy admin charge",
392 "Wellness program fee",
393 "Health savings account contribution",
394 "Employer premium adjustment"
396 {
"Expenses:Supplies",
398 "Office paper & pens",
399 "Printer ink cartridges",
400 "Cleaning supplies – janitorial",
401 "Packaging tape – shipping",
402 "Storage bins purchase",
403 "Paper towels & tissues",
404 "Refill for whiteboard markers",
405 "Safety gloves & masks",
406 "Breakroom coffee supplies",
409 {
"Expenses:Taxes:Social Security",
411 "Social security tax withholding",
412 "Additional SS tax adjustment",
413 "Employer SS contribution",
414 "Self-employment SS tax",
415 "Catch-up SS payment",
416 "Late SS filing fee",
418 "Overpayment refund offset",
419 "Correction to SS tax",
420 "Supplemental SS fee"
422 {
"Expenses:Entertainment:Recreation",
424 "Movie tickets – Friday night",
427 "Amusement park day pass",
428 "Concert ticket – local band",
429 "Game rental – board games",
430 "Streaming movie rental",
432 "Escape room experience",
433 "Comedy club cover charge"
435 {
"Expenses:Online Services",
437 "Cloud backup subscription",
438 "Website hosting fee",
439 "Domain renewal – personal site",
440 "Streaming service – Netflix",
442 "Stock photo download",
443 "Music subscription – Spotify",
444 "Online course enrollment",
445 "Web app premium upgrade",
446 "Paid newsletter subscription"
448 {
"Expenses:Taxes:State/Province",
450 "State income tax payment",
451 "Quarterly state estimated tax",
453 "State tax refund offset",
454 "State franchise tax",
455 "State use tax – online order",
457 "State annual filing fee",
458 "State surtax adjustment",
459 "State environmental surcharge"
461 {
"Expenses:Insurance:Life Insurance",
463 "Term life premium – annual",
464 "Whole life policy contribution",
465 "Beneficiary change fee",
466 "Policy loan interest payment",
467 "Cash value withdrawal fee",
468 "Additional rider premium",
470 "Life insurance underwriting fee",
471 "Group life policy payment",
472 "Late policy premium fee"
474 {
"Expenses:Auto:Fuel",
476 "Gas fill-up – Shell",
477 "Diesel purchase – truck",
478 "Premium fuel – road trip",
479 "Gasoline – self-service",
480 "Fuel for rental car",
481 "Prepaid gas card load",
482 "Gas station coffee & snack",
483 "Topping off tank – holiday",
484 "Discount fuel club purchase",
485 "Fleet vehicle refueling"
492 auto pb_expense = std::make_unique< Wt::WPushButton >(
"load random expenses" );
494 clicked().connect( [=]()
499 std::cout << __FILE__ <<
":" << __LINE__
501 <<
" " << expenses.size()
502 <<
" " << account1->
name()
505 for(
auto expense : expenses )
509 std::cout << __FILE__ <<
":" << __LINE__
511 <<
" " << expense.second.size()
512 <<
" " << expense.first
515 for(
auto second : expense.second )
517 GCW_NUMERIC value(
float( 1234.0 / randomNumber( 1, 99 ) ) );
519 auto number = randomNumber( 0, 9 );
528 expense.second.at( number )
537 auto pb_income = std::make_unique< Wt::WPushButton >(
"load random income" );
539 clicked().connect( [=]()
544 std::cout << __FILE__ <<
":" << __LINE__
546 <<
" " << expenses.size()
547 <<
" " << account1->
name()
552 for(
int i=0; i< 12; i++ )
571 dialog.contents()-> addWidget( std::move( pb_expense ) );
572 dialog.contents()-> addWidget( std::make_unique< Wt::WBreak >() );
573 dialog.contents()-> addWidget( std::move( pb_income ) );
574 dialog.rejectWhenEscapePressed(
true );
575 dialog.setClosable(
true );
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 setTransaction() -> void
auto open_aboutWidget() -> void
auto openSelectedAccount() -> void
auto open_properties() -> void
auto setDoubleLine() -> void
auto setBasicLedger() -> void
CentralWidget * m_centralWidget
Wt::WContainerWidget * m_statusBar
auto setAutosplit() -> void
Wt::WNavigationBar * m_navBar
static WDate currentDate()
#define GCW_NUMERIC
Internal Numeric Type.
const Wt::WFormModel::Field name
const Wt::WFormModel::Field guid
endGCW::Dbo::Accounts::s_accountDefs
auto byFullName(const std::string &_fullName) -> Item::Ptr
Load Account by 'full name' with ':' account separator.