From 40000ee93481681508e51b70fa05b80d35b12d1a Mon Sep 17 00:00:00 2001 From: Christian Stimming Date: Sat, 8 Oct 2011 09:20:07 +0000 Subject: [PATCH] Fix failed assertion if there is no A/R or A/P account involved. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@21389 57a11ea4-9604-0410-9ed3-97b8803252fd --- src/business/business-gnome/dialog-payment.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/business/business-gnome/dialog-payment.c b/src/business/business-gnome/dialog-payment.c index ea9f3e770c..f360b521b8 100644 --- a/src/business/business-gnome/dialog-payment.c +++ b/src/business/business-gnome/dialog-payment.c @@ -837,17 +837,19 @@ PaymentWindow * gnc_ui_payment_new_with_txn (GncOwner *owner, Transaction *txn) return NULL; if (countAssetAccounts(slist) == 0) { - g_message("No asset splits in txn"); + g_message("No asset splits in txn \"%s\"; cannot use this for assigning a payment.", + xaccTransGetDescription(txn)); return NULL; } { - Split *xferaccount_split = getFirstAssetAccountSplit(slist); - Split *postaccount_split = getFirstAPARAccountSplit(slist); - gnc_numeric amount = xaccSplitGetValue(xferaccount_split); + Split *assetaccount_split = getFirstAssetAccountSplit(slist); + Split *postaccount_split = getFirstAPARAccountSplit(slist); // watch out: Might be NULL + gnc_numeric amount = xaccSplitGetValue(assetaccount_split); PaymentWindow *pw = gnc_ui_payment_new(owner, qof_instance_get_book(QOF_INSTANCE(txn))); + g_assert(assetaccount_split); // we can rely on this because of the countAssetAccounts() check above // Fill in the values from the given txn pw->pre_existing_txn = txn; @@ -858,8 +860,9 @@ PaymentWindow * gnc_ui_payment_new_with_txn (GncOwner *owner, Transaction *txn) gnc_ui_payment_window_set_date(pw, &txn_date); } gnc_ui_payment_window_set_amount(pw, gnc_numeric_abs(amount)); - gnc_ui_payment_window_set_xferaccount(pw, xaccSplitGetAccount(xferaccount_split)); - gnc_ui_payment_window_set_postaccount(pw, xaccSplitGetAccount(postaccount_split)); + gnc_ui_payment_window_set_xferaccount(pw, xaccSplitGetAccount(assetaccount_split)); + if (postaccount_split) + gnc_ui_payment_window_set_postaccount(pw, xaccSplitGetAccount(postaccount_split)); return pw; }