Splitted transactions notes

Money Manager Ex Development related posts
(http://github.moneymanagerex.org/)

Moderator: Renato

Post Reply
Nikolay
MMEX Developer
Posts: 1377
Joined: Sat Dec 06, 2008 2:27 pm
Are you a spam bot?: No
Location: Sankt-Petersburg, Russia

Splitted transactions notes

Post by Nikolay »

I an working on Splitted transactions notes

This [<<] magic button will add notes for splitted transactions if pressed.
Attachments
Selection_027.png
(38.99 KiB) Downloaded 649 times

Nikolay
MMEX Developer
Posts: 1377
Joined: Sat Dec 06, 2008 2:27 pm
Are you a spam bot?: No
Location: Sankt-Petersburg, Russia

Re: Splitted transactions notes

Post by Nikolay »

dbwrapper.cpp

Code: Select all

wxString mmDBWrapper::getSplittedTrxNotes(wxSQLite3Database *db, int trxid)
{
	    int transid = trxid;
	    wxString infoStr =  wxEmptyString;
	    double amount;
	    wxString amountStr;
        {
	char sql[]=
	    "select c.categname || case when sc.subcategname not null then ' : '||sc.subcategname else ''end as CATEG "
            ", st.splittransamount as SPLITTRANSAMOUNT "
            "from splittransactions_v1 st "
            "left join category_v1 c on st.categid=c.categid "
            "left join subcategory_v1 sc on st.subcategid=sc.subcategid "
            "where st.transid = ?  "
            "group by st.categid "
            "order by c.categname, sc.subcategname";
            
            wxSQLite3Statement st = db->PrepareStatement(sql); 
            st.Bind(1, transid);

            wxSQLite3ResultSet q1 = st.ExecuteQuery();
            while (q1.NextRow())
            {
				infoStr << q1.GetString(wxT("CATEG"));
				infoStr << wxT(" = ");
				amount = q1.GetDouble(wxT("SPLITTRANSAMOUNT"));
				mmex::formatDoubleToCurrencyEdit(amount, amountStr);
				infoStr << amountStr << wxT("\n");
	    }
            //infoStr.RemoveLast(1);
	}
return infoStr;
}
transdialog.cpp

Code: Select all

EVT_TOGGLEBUTTON(ID_DIALOG_TRANS_TOGGLEBUTTON, mmTransDialog::onSetSplittedNotes)
---
    // Split Category -------------------------------------------
    cSplit_ = new wxCheckBox( itemPanel7, ID_DIALOG_TRANS_SPLITCHKBOX, _("Split"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE );
    cSplit_->SetValue(false);
    cSplit_->SetToolTip(_("Use split Categories"));
    
    trxdlgToggleButton = new wxToggleButton( itemPanel7, ID_DIALOG_TRANS_TOGGLEBUTTON, wxT("<<"), wxDefaultPosition, wxSize(40,-1), 0 );
	trxdlgToggleButton->Enable(false);
	//trxdlgToggleButton->Connect(ID_DIALOG_TRANS_TOGGLEBUTTON, wxEVT_TOGGLEBUTTON, wxKeyEventHandler(mmTransDialog::onSetSplittedNotes), NULL, this);
	
	wxBoxSizer* itemBoxSizer81 = new wxBoxSizer(wxHORIZONTAL);
    itemFlexGridSizer8->AddSpacer(20);  // Fill empty space.
    itemFlexGridSizer8->Add(itemBoxSizer81);
    itemBoxSizer81->Add(cSplit_, 4, wxALIGN_BOTTOM|wxALIGN_LEFT|wxALL, 0);
    itemBoxSizer81->AddSpacer(20);
    itemBoxSizer81->Add(trxdlgToggleButton, 1, wxALIGN_BOTTOM|wxRIGHT|wxALL, 0);
.....
void mmTransDialog::onSetSplittedNotes(wxCommandEvent& event)
{   
    wxString splittedNotes = mmDBWrapper::getSplittedTrxNotes(db_.get(), transID_);
    wxString notes = wxEmptyString;
    bool s = trxdlgToggleButton->GetValue();
    if (s) {
        notes << splittedNotes << textNotes_->GetValue();
    } else {
	    notes << textNotes_->GetValue();
	    notes.Replace(splittedNotes, wxEmptyString);
	}
    textNotes_->SetValue(notes);
}



Post Reply