From 0c7c3356029c89650da31bd1ad0e77d6e764425e Mon Sep 17 00:00:00 2001 From: Geert Janssens Date: Tue, 18 Feb 2014 02:03:44 +0100 Subject: [PATCH] Bug 724578 - Problems clearing incompletely paid invoices --- src/business/business-gnome/dialog-payment.c | 11 ++++++++--- src/engine/gncOwner.c | 10 ++++++---- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/business/business-gnome/dialog-payment.c b/src/business/business-gnome/dialog-payment.c index 5777bb049b..b380f3c459 100644 --- a/src/business/business-gnome/dialog-payment.c +++ b/src/business/business-gnome/dialog-payment.c @@ -666,9 +666,14 @@ gnc_payment_ok_cb (GtkWidget *widget, gpointer data) selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(pw->docs_list_tree_view)); gtk_tree_selection_selected_foreach (selection, get_selected_lots, &selected_lots); - /* If the 'xfer_acct' account and the post account don't have the same - currency, we need to get the user to specify the exchange rate */ - if (!gnc_commodity_equal(xaccAccountGetCommodity(pw->xfer_acct), xaccAccountGetCommodity(pw->post_acct))) + /* When the payment amount is 0, the selected documents cancel each other out + * so no money is actually transferred. + * For non-zero payments money will be transferred between the post account + * and the transfer account. In that case if these two accounts don't have + * the same currency the user is asked to enter the exchange rate. + */ + if (!gnc_numeric_zero_p (pw->amount_tot) && + !gnc_commodity_equal(xaccAccountGetCommodity(pw->xfer_acct), xaccAccountGetCommodity(pw->post_acct))) { XferDialog* xfer; diff --git a/src/engine/gncOwner.c b/src/engine/gncOwner.c index 872671a011..61968d674a 100644 --- a/src/engine/gncOwner.c +++ b/src/engine/gncOwner.c @@ -1034,12 +1034,14 @@ gncOwnerApplyPayment (const GncOwner *owner, Transaction *txn, GList *lots, GList *selected_lots = NULL; /* Verify our arguments */ - if (!owner || !posted_acc || !xfer_acc) return; + if (!owner || !posted_acc + || (!xfer_acc && !gnc_numeric_zero_p (amount)) ) return; g_return_if_fail (owner->owner.undefined); - /* Create a lot for this payment */ - payment_lot = gncOwnerCreatePaymentLot (owner, txn, posted_acc, xfer_acc, - amount, exch, date, memo, num); + /* If there's a real amount to transfer create a lot for this payment */ + if (!gnc_numeric_zero_p (amount)) + payment_lot = gncOwnerCreatePaymentLot (owner, txn, posted_acc, xfer_acc, + amount, exch, date, memo, num); if (lots) selected_lots = lots;