PATCH: Editing transaction - type switch

Page 1 of 1
10 posts
PATCH: Editing transaction - type switch

omalleypat
MMEX Developer

Posts: 175
Joined: Tue Jul 28, 2009 4:34 pm
Location: Atchison, KS
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 319 times
Re: PATCH: Editing transaction - type switch

Nikolay
MMEX Developer

Posts: 2284
Joined: Sat Dec 06, 2008 8:27 am
Location: Sankt-Petersburg, Russia
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

Nikolay
MMEX Developer

Posts: 2284
Joined: Sat Dec 06, 2008 8:27 am
Location: Sankt-Petersburg, Russia
I suggest this code:
The File uttached.
It is not fineshed yet.
Attachments
transdialog.zip
(7.96 KiB) Downloaded 335 times
Re: PATCH: Editing transaction - type switch

omalleypat
MMEX Developer

Posts: 175
Joined: Tue Jul 28, 2009 4:34 pm
Location: Atchison, KS
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

omalleypat
MMEX Developer

Posts: 175
Joined: Tue Jul 28, 2009 4:34 pm
Location: Atchison, KS
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 287 times
Re: PATCH: Editing transaction - type switch

Nikolay
MMEX Developer

Posts: 2284
Joined: Sat Dec 06, 2008 8:27 am
Location: Sankt-Petersburg, Russia
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

Nikolay
MMEX Developer

Posts: 2284
Joined: Sat Dec 06, 2008 8:27 am
Location: Sankt-Petersburg, Russia
Added at revision: 598
Re: PATCH: Editing transaction - type switch

omalleypat
MMEX Developer

Posts: 175
Joined: Tue Jul 28, 2009 4:34 pm
Location: Atchison, KS
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

Nikolay
MMEX Developer

Posts: 2284
Joined: Sat Dec 06, 2008 8:27 am
Location: Sankt-Petersburg, Russia
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

Vadim
MMEX Developer

Posts: 159
Joined: Mon Aug 03, 2009 1:35 am
The revision 598 reverted in branch 0.9.5. We can incorporate this feature in trunk later if this problem is not a problem :-)
Page 1 of 1
Who is online

Users browsing this forum: No registered users and 6 guests

cron