commit 921eb3698264d40dbd9ff5d73e34e3db0419f4dd
Author: Guido Flohr <guido@imperia.net>
Date:   Thu Dec 5 14:39:45 2013 +0200

    determine payment type only on account type

diff --git a/src/business/business-gnome/dialog-payment.c b/src/business/business-gnome/dialog-payment.c
index 1c7c41a..665a5d6 100644
--- a/src/business/business-gnome/dialog-payment.c
+++ b/src/business/business-gnome/dialog-payment.c
@@ -1102,6 +1102,16 @@ static gint predicate_is_apar_account(gconstpointer a,
     else
         return -1;
 }
+static gint predicate_is_ap_account(gconstpointer a,
+                                    gconstpointer user_data)
+{
+    const Split *split = a;
+    const Account *account = xaccSplitGetAccount(split);
+    if (ACCT_TYPE_PAYABLE == xaccAccountGetType(account))
+        return 0;
+    else
+        return -1;
+}
 static Split *getFirstAssetAccountSplit(SplitList* slist)
 {
     GList *r = g_list_find_custom(slist, NULL, &predicate_is_asset_account);
@@ -1118,37 +1128,44 @@ static Split *getFirstAPARAccountSplit(SplitList* slist)
     else
         return NULL;
 }
+static Split *getFirstAPAccountSplit(SplitList* slist)
+{
+    GList *r = g_list_find_custom(slist, NULL, &predicate_is_ap_account);
+    if (r)
+        return r->data;
+    else
+        return NULL;
+}
 
 // ///////////////
 
 gboolean gnc_ui_payment_is_customer_payment(const Transaction *txn)
 {
     SplitList *slist;
-    gboolean result = TRUE;
 
-    Split *assetaccount_split;
+    Split *split;
     gnc_numeric amount;
 
     if (!txn)
-        return result;
+        return TRUE;
 
     // We require the txn to have one split in an A/R or A/P account.
 
     slist = xaccTransGetSplitList(txn);
     if (!slist)
-        return result;
+        return TRUE;
     if (countAssetAccounts(slist) == 0)
     {
         g_message("No asset splits in txn \"%s\"; cannot use this for assigning a payment.",
                   xaccTransGetDescription(txn));
-        return result;
+        return TRUE;
     }
 
-    assetaccount_split = getFirstAssetAccountSplit(slist);
-    amount = xaccSplitGetValue(assetaccount_split);
-    result = gnc_numeric_positive_p(amount); // positive amounts == customer
-    //g_message("Amount=%s", gnc_numeric_to_string(amount));
-    return result;
+    split = getFirstAPAccountSplit(slist);
+    if (!split)
+        return TRUE;
+
+    return FALSE;
 }
 
 // ///////////////
