Bug 321317 - Transfer direction changes as details are being entered
Summary: Transfer direction changes as details are being entered
Status: RESOLVED FIXED
Alias: None
Product: kmymoney
Classification: Applications
Component: general (show other bugs)
Version: git (master)
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: ---
Assignee: KMyMoney Devel Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-06-18 11:48 UTC by Ian Neal
Modified: 2013-07-14 10:28 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Fix inconsistencies in transactionform labelling. Also BUG:321108 - Fix 'Cannot enter transactions without a payee'. (10.37 KB, patch)
2013-07-05 16:19 UTC, allan
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ian Neal 2013-06-18 11:48:13 UTC
The transfer direction does not match the payee field direction when creating / editing a transfer transaction.
Version 4.6.90-ad3e78cc21

Reproducible: Always

Steps to Reproduce:
1. Start to add new entry
2. Before you start typing fields say "Pay to" and "Transfer to"
3. Put in payee details
4. Select an account to transfer to
5. Note field names
Actual Results:  
1. First field still says "Pay to", second field now says "Transfer from"
2. Adding an amount then clicking OK, fields briefly change to "Pay to" / "Transfer to" but then go to "From" / "Transfer From"
3. When you click on "Edit" the fields become "From" / "Transfer to"

Expected Results:  
1. First and second field match, so either "Pay to" / "Transfer to" or "From" / "Transfer from"
2. When you start the Edit that the fields stay as they were before you started the Edit

If you have created a "to" transaction, click on Edit, the fields are "Pay to" / "Transfer from"
Comment 1 Marko Käning 2013-06-22 08:29:59 UTC
Seeing on Mac OSX the same!
Installed through MacPorts: kmymoney4-devel @4.6-20130506_0

I have a newly downloaded transfer transaction in one of my accounts, but the receiving account wasn't properly assigned by KMM.

When I now want to edit the transaction accordingly suddenly the transfer direction is inverted.

There's no way to recover from this. The transaction stays in my ledgers as is and the balances of the three accounts involved are all incorrect.
Comment 2 David Houlden 2013-06-22 09:52:44 UTC
This behaviour started with git commit 94935cf78e. Since Allan has plans to revisit this patch because of bug 321108 maybe he can look at this at the same time.
Comment 3 allan 2013-06-22 10:21:44 UTC
(In reply to comment #1)
> Seeing on Mac OSX the same!
> Installed through MacPorts: kmymoney4-devel @4.6-20130506_0
> 
> I have a newly downloaded transfer transaction in one of my accounts, but
> the receiving account wasn't properly assigned by KMM.
> 
> When I now want to edit the transaction accordingly suddenly the transfer
> direction is inverted.
> 
> There's no way to recover from this. The transaction stays in my ledgers as
> is and the balances of the three accounts involved are all incorrect.

Can you show the steps/transaction needed to demonstrate this, please.

I've not recently, if ever, touched those labels, I don't believe, but perhaps have caused a change in behaviour in that area.
Comment 4 David Houlden 2013-06-22 10:41:25 UTC
Allan, your commit 94935cf78e added some code which does appear to change the labels. 

In the diff for transactioneditor.cpp

+    } else {
+      if (categoryLabel->text() != i18n("Category")) {
+        if (categoryLabel->text() == i18n("Transfer to")) {
+          categoryLabel->setText(i18n("Transfer from"));
+          cashflow->setDirection(KMyMoneyRegister::Payment);
+        } else {
+          categoryLabel->setText(i18n("Transfer to"));
+          cashflow->setDirection(KMyMoneyRegister::Deposit);
+        }
+      }
+      dynamic_cast<kMyMoneyEdit*>(m_editWidgets["amount"])->setValue(val.abs());
Comment 5 allan 2013-06-22 13:00:37 UTC
(In reply to comment #4)
> Allan, your commit 94935cf78e added some code which does appear to change
> the labels. 
> 
> In the diff for transactioneditor.cpp
> 
> +    } else {
> +      if (categoryLabel->text() != i18n("Category")) {
> +        if (categoryLabel->text() == i18n("Transfer to")) {
> +          categoryLabel->setText(i18n("Transfer from"));
> +          cashflow->setDirection(KMyMoneyRegister::Payment);
> +        } else {
> +          categoryLabel->setText(i18n("Transfer to"));
> +          cashflow->setDirection(KMyMoneyRegister::Deposit);
> +        }
> +      }
> +     
> dynamic_cast<kMyMoneyEdit*>(m_editWidgets["amount"])->setValue(val.abs());

Apologies, you're right.  I need to investigate further as, just removing that added code, I get back to this problem -
"
...when using the transaction form and doing a multi-transaction edit, on attempting to enter an amount, it was not accepted unless the amount was negative.
"
Comment 6 allan 2013-06-27 23:24:59 UTC
(In reply to comment #0)
<snip>
> Expected Results:  
> 1. First and second field match, so either "Pay to" / "Transfer to" or
> "From" / "Transfer from"
> 2. When you start the Edit that the fields stay as they were before you
> started the Edit
> 

Apart from the change I made, referred to by Dave, the logic in this area is a little strange to me.
For instance -
"
 if (categoryLabel->text() == i18n("Transfer to")) {
   categoryLabel->setText(i18n("Transfer from"));
"

This seems to be saying that every time this is executed, the label will flip-flop.  Why should that be?  Why take into account the previous operation?  If my transaction is "Transfer to", and I click Edit, why does the label change to "Transfer from"?

Then, from your submission, 
> 1. First and second field match, so either "Pay to" / "Transfer to" or
> "From" / "Transfer from"
Why should the two fields match.  If I'm creating a transfer from one account to another, where does the payee come into it?  It being a new transaction, there is no existing payee.  In the receiving account, the transaction would show as a deposit from that payee, when it's actually just from the other account.

Then, in a multi-transaction transfer, after selecting two existing transactions and clicking Edit, the Pay to field is initially blank.
Comment 7 allan 2013-07-01 16:31:29 UTC
Apart from the previous, there were a few other inconsistencies, which I've attended to.

Would either of you care to test the patch before I submit it, in case I've missed anything?

Allan
Comment 8 David Houlden 2013-07-01 17:07:14 UTC
Always happy to do a bit of testing. Send the patch please Allan. I should be able to find some time tomorrow.
Comment 9 allan 2013-07-01 18:04:49 UTC
(In reply to comment #8)
> Always happy to do a bit of testing. Send the patch please Allan. I should
> be able to find some time tomorrow.

I've attached the patch, Dave [off-line].  It includes also the reinstatement of
the previous Payee behaviour.
Comment 10 David Houlden 2013-07-02 16:24:18 UTC
Allan, I've been testing the patch and I've only found one thing which looks a bit strange. 

I have a transfer from Account1 to Account2. (With or without a payee, it makes no difference). 
Go into the ledger for Account2 and highlight that transfer transaction. 
The transaction form shows "From" and "Transfer from".
Click Edit.
The form now shows "Pay to" and "Transfer from"
Now click Enter or Cancel and it reverts back to showing "From" and "Transfer from"

It doesn't seem to affect the transaction, just looks odd as it changes and could be confusing.
Comment 11 allan 2013-07-03 10:31:11 UTC
Practically all the changes were to do with that type of behaviour.  There are seven or eight places where the the category label and cash-flow direction settings are checked/changed.  This is one condition I missed finding.  Thanks Dave.

Having the transaction form seems to add an additional layer of complication, compared to editing directly in the ledger.  The category label and cash-flow direction settings are inter-related, but separate.  There's probably a case for doing the testing and setting in just one place, instead of piecemeal.

I send you the modified patch off-line.
Comment 12 David Houlden 2013-07-04 18:25:05 UTC
It looks good now Allan. I've tried everything I typically do in the ledger and couldn't see anything wrong. Also tried multi transaction edit which I never use and that looked ok according to my understanding of how it works.
Comment 13 allan 2013-07-05 16:19:12 UTC
Created attachment 80976 [details]
Fix inconsistencies in transactionform labelling. Also BUG:321108 - Fix 'Cannot enter transactions without a payee'.

There were several places where the cash-flow direction and the category label were out-of-sync.
Also includes removal of Payee as mandatory item for BUG:321108, which had been added in git commit 94935cf78e.
I'll hold off committing for 7-10 days, in case anyone has doubts.
Comment 14 Marko Käning 2013-07-11 20:43:45 UTC
The patch seems to work fine with the latest git here.
Comment 15 allan 2013-07-11 21:15:09 UTC
(In reply to comment #14)
> The patch seems to work fine with the latest git here.

Thanks, Marko, that's good.  I'll go ahead to commit in the next day or so.
Comment 16 allan 2013-07-14 10:28:29 UTC
Git commit 7c6b050b0269b5651fb10c58c8d4a81d1de2c3f9 by Allan Anderson.
Committed on 01/07/2013 at 10:49.
Pushed by allananderson into branch 'master'.
Related: bug 321108

M  +1    -2    kmymoney/dialogs/keditscheduledlg.cpp
M  +36   -31   kmymoney/dialogs/transactioneditor.cpp
M  +0    -10   kmymoney/widgets/kguiutils.cpp

http://commits.kde.org/kmymoney/7c6b050b0269b5651fb10c58c8d4a81d1de2c3f9