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>
11#ifdef STATUS_BAR_CLOCK
16#include "../GnuCashew.h"
17#include "../Eng/TransactionManager.h"
41 auto lw =
setLayout( std::make_unique< Wt::WVBoxLayout >() );
55#ifdef STATUS_BAR_CLOCK
57 timer-> setInterval( std::chrono::seconds(1) );
74 link.setTarget( Wt::LinkTarget::NewWindow );
75 navBar()-> setResponsive(
true );
76 navBar()-> addStyleClass(
"navbar-light bg-light" );
77 navBar()-> setTitle(
"GCW", link );
83 auto w_ = std::make_unique< GCW::Gui::MainMenu >(
this );
84 m_mainMenu = w_.get();
85 navBar()-> addMenu( std::move( w_ ) );
91 navBar()-> addWidget( std::make_unique< LanguagePicker >(), Wt::AlignmentFlag::Right );
96 toolBar()-> addButton( std::make_unique< PushButton >(
TR(
"gcw.MainWidget.tb.save" ) ) );
97 toolBar()-> addButton( std::make_unique< PushButton >(
TR(
"gcw.MainWidget.tb.close" ) ) );
98 toolBar()-> addButton( std::make_unique< PushButton >(
TR(
"gcw.MainWidget.tb.newInvoice" ) ) );
99 toolBar()-> addButton( std::make_unique< PushButton >(
TR(
"gcw.MainWidget.tb.open" ) ) );
102 auto b = std::make_unique< PushButton >(
TR(
"gcw.MainWidget.tb.edit" ) );
104 toolBar()-> addButton( std::move(b) );
105 e-> clicked().connect( [=](){ openSelectedAccount(); });
108 toolBar()-> addButton( std::make_unique< PushButton >(
TR(
"gcw.MainWidget.tb.new" ) ) );
109 toolBar()-> addButton( std::make_unique< PushButton >(
TR(
"gcw.MainWidget.tb.delete" ) ) );
113 auto b = std::make_unique< PushButton >(
"devtest" );
115 toolBar()-> addButton( std::move(b) );
116 e-> clicked().connect( [=](){ test(); });
120#ifdef STATUS_BAR_CLOCK
121 statusBar()-> addNew< Wt::WText >(
"status bar" );
122 m_clock = statusBar()-> addNew< Wt::WText >();
123 m_clock-> setAttributeValue(
"style",
"float:right;" );
132#ifdef STATUS_BAR_CLOCK
143 if( !
GCW::app()-> gnucashew_session().isOpen() )
146 auto dialog = addChild( std::make_unique< Wt::WDialog >(
TR(
"gcw.PropertiesWidget.titleBar" ) ) );
147 dialog-> rejectWhenEscapePressed(
true );
148 dialog-> contents()-> addNew< GCW::Gui::FilePropertiesWidget >();
151 finished().connect( [=]()
153 removeChild( dialog );
162 auto templt = std::make_unique< Wt::WTemplate >(
TR(
"gcw.AboutWidget.about" ) );
163 templt-> bindString(
"version",
"none" );
164 templt-> bindString(
"buildid",
"none" );
165 templt-> bindString(
"finance",
"none (yet)" );
167 auto dialog = addChild( std::make_unique< Wt::WDialog >(
TR(
"gcw.AboutWidget.titleBar" ) ) );
168 dialog-> rejectWhenEscapePressed(
true );
169 dialog-> contents()-> addWidget( std::move( templt ) );
172 finished().connect( [=]()
174 removeChild( dialog );
183 centralWidget()-> activateAccountsTreeView();
184 centralWidget()-> accountsTreeView()-> editSelectedAccount();
192 std::cout << __FILE__ <<
":" << __LINE__ <<
" " << std::endl;
200 std::cout << __FILE__ <<
":" << __LINE__ <<
" " << std::endl;
208 std::cout << __FILE__ <<
":" << __LINE__ <<
" " << std::endl;
216 if(
auto accountRegister = centralWidget()-> currentAccountRegister() )
218 auto doubleLine = m_mainMenu-> menuItem(
TR(
"gcw.MainWidget.mu.view.doubleline" ) );
220 accountRegister-> setDoubleLine( doubleLine-> isChecked() );
227auto randomNumber(
int _min,
int _max )->
int
229 static std::random_device rd;
230 static std::mt19937 gen( rd() );
232 std::uniform_int_distribution<> dist( _min, _max );
234 auto retVal = dist( gen );
241test_tableview()->
void
243 auto model = std::make_shared< Wt::WStandardItemModel >();
244 for(
int row = 0; row< 3; row++ )
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-> appendRow( std::move( rowset ) );
256 auto tableView = std::make_unique< Wt::WTableView >();
257 tableView-> setSelectionBehavior ( Wt::SelectionBehavior::Items );
260 tableView-> setSelectionMode ( Wt::SelectionMode::Extended );
261 tableView-> setColumnResizeEnabled (
false );
262 tableView-> setAlternatingRowColors (
true );
263 tableView-> setModel ( model );
265 auto pbgo = std::make_unique< Wt::WPushButton >(
"go" );
267 clicked().connect( [=]()
269 std::cout << __FILE__ <<
":" << __LINE__ <<
" " << std::endl;
272 std::vector< std::unique_ptr< Wt::WStandardItem > > rowset;
273 for(
int col = 0; col< 3; col++ )
275 auto item = std::make_unique< Wt::WStandardItem >(
Wt::WString(
"row{1} col{2}").arg( row ).arg( col) );
276 rowset.push_back( std::move( item ) );
279 model-> insertRow( 2, std::move( rowset ) );
285 dialog.contents()-> addWidget( std::move( pbgo ) );
286 dialog.contents()-> addWidget( std::move( tableView ) );
287 dialog.rejectWhenEscapePressed(
true );
288 dialog.setResizable(
true );
289 dialog.setMinimumSize( 600, 300 );
290 dialog.setClosable(
true );
302load_random_transactions()
304 std::map< std::string, std::vector< std::string > > expenses = {
305 {
"Expenses:Medical Expenses",
307 "Copay for doctor visit",
308 "Prescription refill – CVS",
309 "Dental cleaning – Dr. Smith",
310 "Urgent care visit – weekend",
311 "Eye exam – optometrist",
312 "Physical therapy session",
313 "Lab tests – Quest Diagnostics",
314 "Over-the-counter medication",
315 "Hospital parking fee",
316 "Flu shot – Walgreens"
318 {
"Expenses:Laundry/Dry Cleaning",
320 "Dry cleaning suit – Cleaners Plus",
321 "Wash & fold service",
322 "Shirt pressing – Express Cleaners",
323 "Comforter dry cleaned",
324 "Stain removal – silk blouse",
325 "Laundry card refill",
326 "Pickup & delivery laundry",
328 "Curtain dry cleaning",
329 "Weekly laundry service"
331 {
"Expenses:Groceries",
333 "Weekly grocery run – Walmart",
334 "Produce market – fresh veggies",
335 "Milk and bread – local store",
336 "Bulk items – Costco",
337 "Organic produce – Whole Foods",
338 "Meat & seafood purchase",
339 "Baking supplies – holiday",
340 "Frozen goods – Aldi",
341 "Snacks and beverages",
342 "Pet food – grocery aisle"
346 "Monthly cable bill – Spectrum",
347 "Sports channel add-on",
348 "Premium movie package",
350 "Service technician visit",
352 "Internet & cable bundle",
353 "Pay-per-view boxing event",
354 "Channel upgrade request",
355 "Equipment rental fee"
357 {
"Expenses:Taxes:Other Tax",
359 "Local occupancy tax",
360 "Vehicle registration tax",
362 "Parking permit tax",
363 "Short-term rental tax",
364 "City environmental fee",
365 "Import duty – online order",
366 "Special assessment tax",
367 "Utility usage surcharge",
370 {
"Expenses:Computer",
372 "New laptop purchase",
373 "External hard drive – backup",
374 "Software subscription – Adobe",
375 "Keyboard & mouse combo",
376 "Replacement charger",
378 "Anti-virus renewal",
379 "Laptop repair service",
380 "Cloud storage subscription",
381 "Graphics card upgrade"
385 "Monthly mobile bill – Verizon",
387 "Data overage charge",
388 "International calling plan",
389 "Screen protector purchase",
390 "Device insurance premium",
392 "SIM card replacement",
393 "Voicemail-to-text add-on",
394 "Mobile hotspot charge"
398 "Textbook purchase – college",
399 "E-book download – Kindle",
400 "Magazine subscription",
401 "Used books – thrift store",
402 "Study guide – exam prep",
403 "Children’s storybook",
404 "Hardcover bestseller",
406 "Audio book subscription",
409 {
"Expenses:Insurance:Health Insurance",
411 "Monthly premium – Blue Cross",
412 "Policy renewal fee",
413 "Dependent coverage add-on",
415 "Out-of-network reimbursement",
416 "Health plan deductible payment",
417 "Policy admin charge",
418 "Wellness program fee",
419 "Health savings account contribution",
420 "Employer premium adjustment"
422 {
"Expenses:Supplies",
424 "Office paper & pens",
425 "Printer ink cartridges",
426 "Cleaning supplies – janitorial",
427 "Packaging tape – shipping",
428 "Storage bins purchase",
429 "Paper towels & tissues",
430 "Refill for whiteboard markers",
431 "Safety gloves & masks",
432 "Breakroom coffee supplies",
435 {
"Expenses:Taxes:Social Security",
437 "Social security tax withholding",
438 "Additional SS tax adjustment",
439 "Employer SS contribution",
440 "Self-employment SS tax",
441 "Catch-up SS payment",
442 "Late SS filing fee",
444 "Overpayment refund offset",
445 "Correction to SS tax",
446 "Supplemental SS fee"
448 {
"Expenses:Entertainment:Recreation",
450 "Movie tickets – Friday night",
453 "Amusement park day pass",
454 "Concert ticket – local band",
455 "Game rental – board games",
456 "Streaming movie rental",
458 "Escape room experience",
459 "Comedy club cover charge"
461 {
"Expenses:Online Services",
463 "Cloud backup subscription",
464 "Website hosting fee",
465 "Domain renewal – personal site",
466 "Streaming service – Netflix",
468 "Stock photo download",
469 "Music subscription – Spotify",
470 "Online course enrollment",
471 "Web app premium upgrade",
472 "Paid newsletter subscription"
474 {
"Expenses:Taxes:State/Province",
476 "State income tax payment",
477 "Quarterly state estimated tax",
479 "State tax refund offset",
480 "State franchise tax",
481 "State use tax – online order",
483 "State annual filing fee",
484 "State surtax adjustment",
485 "State environmental surcharge"
487 {
"Expenses:Insurance:Life Insurance",
489 "Term life premium – annual",
490 "Whole life policy contribution",
491 "Beneficiary change fee",
492 "Policy loan interest payment",
493 "Cash value withdrawal fee",
494 "Additional rider premium",
496 "Life insurance underwriting fee",
497 "Group life policy payment",
498 "Late policy premium fee"
500 {
"Expenses:Auto:Fuel",
502 "Gas fill-up – Shell",
503 "Diesel purchase – truck",
504 "Premium fuel – road trip",
505 "Gasoline – self-service",
506 "Fuel for rental car",
507 "Prepaid gas card load",
508 "Gas station coffee & snack",
509 "Topping off tank – holiday",
510 "Discount fuel club purchase",
511 "Fleet vehicle refueling"
518 auto pb_expense = std::make_unique< Wt::WPushButton >(
"load random expenses" );
520 clicked().connect( [=]()
525 std::cout << __FILE__ <<
":" << __LINE__
527 <<
" " << expenses.size()
528 <<
" " << account1->
name()
531 for(
auto expense : expenses )
535 std::cout << __FILE__ <<
":" << __LINE__
537 <<
" " << expense.second.size()
538 <<
" " << expense.first
541 for(
auto second : expense.second )
543 GCW_NUMERIC value(
float( 1234.0 / randomNumber( 1, 99 ) ) );
545 auto number = randomNumber( 0, 9 );
554 expense.second.at( number )
563 auto pb_income = std::make_unique< Wt::WPushButton >(
"load random income" );
565 clicked().connect( [=]()
570 std::cout << __FILE__ <<
":" << __LINE__
572 <<
" " << expenses.size()
573 <<
" " << account1->
name()
578 for(
int i=0; i< 12; i++ )
597 dialog.contents()-> addWidget( std::move( pb_expense ) );
598 dialog.contents()-> addWidget( std::make_unique< Wt::WBreak >() );
599 dialog.contents()-> addWidget( std::move( pb_income ) );
600 dialog.rejectWhenEscapePressed(
true );
601 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
auto do_statusBarUpdate() -> void
CentralWidget * m_centralWidget
Wt::WContainerWidget * m_statusBar
auto setAutosplit() -> void
Wt::WNavigationBar * m_navBar
static WDateTime currentDateTime()
static WDate currentDate()
void addChild(std::unique_ptr< WObject > child)
#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.