PATCH: Editing transaction - type switch

Money Manager Ex Development related posts for both Android and Desktop

Moderator: Renato

Post Reply
omalleypat
Super MMEX User
Posts: 112
Joined: Tue Jul 28, 2009 10:34 pm
Are you a spam bot?: No
Location: Atchison, KS

PATCH: Editing transaction - type switch

Post by omalleypat »

Currently if you accidentally enter a deposit as a withdrawal, then edit the transaction and switch from withdrawal to deposit, you lose your payee info and have to reenter it. This patch keeps the payee info if the "old" transaction type was deposit or withdrawal and the "new" type is deposit or withdrawal. Transfers keep the original behavior.

I'm not sure if my method for getting the original transaction type is the best way to do it, but it works...

Please check it out and apply to trunk+0.9.5 branch.
Attachments
transdialog.zip
Patch for editing transaction type
(1.02 KiB) Downloaded 523 times
Nikolay
MMEX Developer
Posts: 1535
Joined: Sat Dec 06, 2008 2:27 pm
Are you a spam bot?: No
Location: Sankt-Petersburg, Russia

Re: PATCH: Editing transaction - type switch

Post by Nikolay »

Hi,

Wery good idea.
I suggest anothe code.

Code: Select all

void mmTransDialog::updateControlsForTransType()
{
    wxStaticText* st = (wxStaticText*)FindWindow(ID_DIALOG_TRANS_STATIC_FROM);
    wxStaticText* stp = (wxStaticText*)FindWindow(ID_DIALOG_TRANS_STATIC_PAYEE);

	// If this is an edited transaction, look to see what the original transtype was
	wxString PayeeName = wxT("");
	int PayeeId = -1;
//	if (edit_)
//	{
	   mmBEGINSQL_LITE_EXCEPTION;
		
		static const char sql[] = 
        "select c.PAYEEID as PAYEEID, p.PAYEENAME as PAYEENAME from CHECKINGACCOUNT_V1 c, PAYEE_V1 p " 
		"where c.payeeid=p.payeeid and TRANSID = ? ";
		wxSQLite3Statement st = db_->PrepareStatement(sql);
        st.Bind(1, transID_);
		wxSQLite3ResultSet q1 = st.ExecuteQuery();

		//if (q1.NextRow())
			PayeeName = q1.GetString(wxT("PAYEENAME"));
			PayeeId = q1.GetInt(wxT("PAYEEID"));
		q1.Finalize();
		mmENDSQL_LITE_EXCEPTION 
//	}
	//Evaluate the new transaction type and act accordingly
     if (choiceTrans_->GetSelection() == DEF_WITHDRAWAL)
     {
		fillControls();
        st->Show(false);
        bTo_->Show(false);
        stp->SetLabel(_("Payee"));
		
		// Keep Payee info if old type was deposit or withdrawal 
		//note transTypeString will be wxT("") if new transaction (not edited)
//		if (transTypeString != wxT("Deposit") && transTypeString != wxT("Withdrawal"))
//        {
//			bPayee_->SetLabel(_("Select Payee"));
		bPayee_->SetLabel(PayeeName);
		payeeID_ = PayeeId;
//		}
        toID_    = -1;
       
        bAdvanced_->Enable(false);
        bPayee_->SetToolTip(_("Specify to whom the transaction is going to or coming from "));
     }
     else if (choiceTrans_->GetSelection() == DEF_DEPOSIT)
    {
//        payeeID_ = PayeeId;
        fillControls();
        bTo_->Show(false);
        st->Show(false);    

        stp->SetLabel(_("Payee"));
		// Keep Payee info if old type was deposit or withdrawal
		//note transTypeString will be wxT("") if new transaction (not edited)
//		if (transTypeString != wxT("Deposit") && transTypeString != wxT("Withdrawal"))
//		{
//        bPayee_->SetLabel(_("Select Payee"));
		bPayee_->SetLabel(PayeeName);
        payeeID_ = PayeeId;
//		}
        toID_    = -1;
        bAdvanced_->Enable(false);
        bPayee_->SetToolTip(_("Specify to whom the transaction is going to or coming from "));
    }
    else if (choiceTrans_->GetSelection() == DEF_TRANSFER)
    {
        bTo_->SetLabel(_("Select To Account"));
        toID_    = -1;
        
        bTo_->Show(true);
        st->Show(true);
        stp->SetLabel(_("From"));   
        bAdvanced_->Enable(true);

        wxString acctName = mmDBWrapper::getAccountName(db_, accountID_);
        bPayee_->SetLabel(acctName);
        payeeID_ = accountID_;

        bPayee_->SetToolTip(_("Specify the account from which the transfer is occurring"));
    }
}
Nikolay
MMEX Developer
Posts: 1535
Joined: Sat Dec 06, 2008 2:27 pm
Are you a spam bot?: No
Location: Sankt-Petersburg, Russia

Re: PATCH: Editing transaction - type switch

Post by Nikolay »

I suggest this code:
The File uttached.
It is not fineshed yet.
Attachments
transdialog.zip
(7.96 KiB) Downloaded 562 times
omalleypat
Super MMEX User
Posts: 112
Joined: Tue Jul 28, 2009 10:34 pm
Are you a spam bot?: No
Location: Atchison, KS

Re: PATCH: Editing transaction - type switch

Post by omalleypat »

Nikolay,

Yours looks more elegant than mine (haven't tested yet). I was thinking, would it make sense if the user clicks the "Edit" button to only show the relevant transaction type? For example, I can't see someone clicking edit to change a transfer transaction to a withdrawal. If you click edit on a deposit, you should only be able to change to a withdrawal (or leave as a deposit) and not have the option for transfer at all. Similarly, if you edit a transfer, you should not be able to switch it to a deposit or withdrawal. I think this would streamline the user experience a bit.

I can work on these changes, but I'd like to make sure others agree before I start...

Pat
omalleypat
Super MMEX User
Posts: 112
Joined: Tue Jul 28, 2009 10:34 pm
Are you a spam bot?: No
Location: Atchison, KS

Re: PATCH: Editing transaction - type switch

Post by omalleypat »

So I decided to go ahead anyway...here is a diff off of r580.

I used several of Nikolay's suggestions (although the changes to the .h file are not needed in the way I did it). Basically there are several behavioral changes in the transaction dialog (most of which I would consider bugfixes):

For a NEW transaction:
If you start to enter info then switch to "Deposit" from the default withdrawal, you will not have to reenter the payee.
If you switch from transfer to deposit/withdrawal, the category and payee will be cleared.

For an EDITED transaction:
If you are editing a deposit/withdrawal, you no longer have the option of changing the type to transfer (transfer removed from combobox). Also, you will not lose payee info you switch to deposit/withdrawal.
If you are editing a transfer, you no longer have the option of changing the type to deposit/withdrawal (combobox greyed out).
Attachments
transdialog_r580_diff.zip
Changes to Transaction Dialog
(2.05 KiB) Downloaded 496 times
Nikolay
MMEX Developer
Posts: 1535
Joined: Sat Dec 06, 2008 2:27 pm
Are you a spam bot?: No
Location: Sankt-Petersburg, Russia

Re: PATCH: Editing transaction - type switch

Post by Nikolay »

Hi,

I like this new functionality.
It would be nice store the Category:Subcategory info when you editing the transaction and change a Payee.
Is it possible?

Regards,
Nikolay

PS Is anybody need to change the type of the transaction? May be hide the type selector when they edit the transaction? It should be easy to develop and understand for users.
Nikolay
MMEX Developer
Posts: 1535
Joined: Sat Dec 06, 2008 2:27 pm
Are you a spam bot?: No
Location: Sankt-Petersburg, Russia

Re: PATCH: Editing transaction - type switch

Post by Nikolay »

Added at revision: 598
omalleypat
Super MMEX User
Posts: 112
Joined: Tue Jul 28, 2009 10:34 pm
Are you a spam bot?: No
Location: Atchison, KS

Re: PATCH: Editing transaction - type switch

Post by omalleypat »

Nikolay wrote: It would be nice store the Category:Subcategory info when you editing the transaction and change a Payee. Is it possible?
I'll look into it.
Nikolay
MMEX Developer
Posts: 1535
Joined: Sat Dec 06, 2008 2:27 pm
Are you a spam bot?: No
Location: Sankt-Petersburg, Russia

Re: PATCH: Editing transaction - type switch

Post by Nikolay »

The patch that has been discussed here should be deleted. Users should have the possibility to change a transaction type after an import, for example.
Vadim
Super MMEX User
Posts: 142
Joined: Mon Aug 03, 2009 7:35 am
Are you a spam bot?: No

Re: PATCH: Editing transaction - type switch

Post by Vadim »

The revision 598 reverted in branch 0.9.5. We can incorporate this feature in trunk later if this problem is not a problem :-)
Post Reply