Page 1 of 1

PATCH: Editing transaction - type switch

Posted: Sat Oct 10, 2009 8:18 pm
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.

Re: PATCH: Editing transaction - type switch

Posted: Sat Oct 10, 2009 10:48 pm
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"));
    }
}

Re: PATCH: Editing transaction - type switch

Posted: Sun Oct 11, 2009 12:26 pm
by Nikolay
I suggest this code:
The File uttached.
It is not fineshed yet.

Re: PATCH: Editing transaction - type switch

Posted: Sun Oct 11, 2009 1:22 pm
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

Re: PATCH: Editing transaction - type switch

Posted: Mon Oct 12, 2009 9:30 pm
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).

Re: PATCH: Editing transaction - type switch

Posted: Tue Oct 13, 2009 8:02 am
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.

Re: PATCH: Editing transaction - type switch

Posted: Tue Oct 13, 2009 9:08 am
by Nikolay
Added at revision: 598

Re: PATCH: Editing transaction - type switch

Posted: Tue Oct 13, 2009 1:17 pm
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.

Re: PATCH: Editing transaction - type switch

Posted: Mon Nov 02, 2009 2:44 pm
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.

Re: PATCH: Editing transaction - type switch

Posted: Mon Nov 02, 2009 3:07 pm
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 :-)