gnucash maint: Don't require prices in Scheduled Transactions with marker commodity splits.

John Ralls jralls at code.gnucash.org
Fri Oct 30 17:07:41 EDT 2015


Updated	 via  https://github.com/Gnucash/gnucash/commit/d061f6e9 (commit)
	from  https://github.com/Gnucash/gnucash/commit/ce838d3c (commit)



commit d061f6e9628e5c51af4620d69e1fd4b7962b2ccc
Author: John Ralls <jralls at ceridwen.us>
Date:   Fri Oct 30 14:07:24 2015 -0700

    Don't require prices in Scheduled Transactions with marker commodity splits.
    
    Bug 754192 - Since Last Run Dialog asks for security price even if not needed
    Bug 662126 - Cannot create scheduled transaction for dividend reinvestment
    
    If a split in an SX has a 0 amount, don't make its commodity the transaction
    commodity, set the multi-commodity flag, or create a variable for it.
    
    Make the warning about not being able to auto-create SXes with variables
    or multiple commodities more explicit about the latter.

diff --git a/src/app-utils/gnc-sx-instance-model.c b/src/app-utils/gnc-sx-instance-model.c
index cc7dbbf..6d8a24d 100644
--- a/src/app-utils/gnc-sx-instance-model.c
+++ b/src/app-utils/gnc-sx-instance-model.c
@@ -193,6 +193,7 @@ _get_vars_helper(Transaction *txn, void *var_hash_data)
         gnc_commodity *split_cmdty = NULL;
         GncGUID *acct_guid;
         Account *acct;
+        gnc_numeric split_amount;
 
         s = (Split*)split_list->data;
         kvpf = xaccSplitGetSlots(s);
@@ -203,12 +204,14 @@ _get_vars_helper(Transaction *txn, void *var_hash_data)
         acct_guid = kvp_value_get_guid(kvp_val);
         acct = xaccAccountLookup(acct_guid, gnc_get_current_book());
         split_cmdty = xaccAccountGetCommodity(acct);
-        if (first_cmdty == NULL)
+        split_amount = xaccSplitGetAmount(s);
+        if (!gnc_numeric_zero_p(split_amount) && first_cmdty == NULL)
         {
             first_cmdty = split_cmdty;
         }
 
-        if (! gnc_commodity_equal(split_cmdty, first_cmdty))
+        if (!gnc_numeric_zero_p(split_amount) &&
+            ! gnc_commodity_equal(split_cmdty, first_cmdty))
         {
             GncSxVariable *var;
             GString *var_name;
diff --git a/src/gnome/dialog-sx-editor.c b/src/gnome/dialog-sx-editor.c
index 44496e8..d35d50b 100644
--- a/src/gnome/dialog-sx-editor.c
+++ b/src/gnome/dialog-sx-editor.c
@@ -608,6 +608,7 @@ gnc_sxed_check_consistent( GncSxEditorDialog *sxed )
                 Account *acct;
                 gnc_commodity *split_cmdty;
                 txnCreditDebitSums *tcds;
+                gnc_numeric split_amount;
 
                 s = (Split*)splitList->data;
                 t = xaccSplitGetParent( s );
@@ -632,11 +633,14 @@ gnc_sxed_check_consistent( GncSxEditorDialog *sxed )
                 acct_guid = kvp_value_get_guid( v );
                 acct = xaccAccountLookup( acct_guid, gnc_get_current_book ());
                 split_cmdty = xaccAccountGetCommodity(acct);
-                if (base_cmdty == NULL)
+                split_amount = xaccSplitGetAmount(s);
+                if (!gnc_numeric_zero_p(split_amount) && base_cmdty == NULL)
                 {
                     base_cmdty = split_cmdty;
                 }
-                multi_commodity |= !gnc_commodity_equal(split_cmdty, base_cmdty);
+                multi_commodity |= (!gnc_numeric_zero_p(split_amount) &&
+                                    !gnc_commodity_equal(split_cmdty,
+                                                         base_cmdty));
 
                 v = kvp_frame_get_slot_path( f,
                                              GNC_SX_ID,
@@ -792,6 +796,7 @@ gnc_sxed_check_consistent( GncSxEditorDialog *sxed )
         {
             gnc_warning_dialog(sxed->dialog, "%s",
                                _("Scheduled Transactions with variables "
+                                 "or involving more than one commodity "
                                  "cannot be automatically created."));
             return FALSE;
         }



Summary of changes:
 src/app-utils/gnc-sx-instance-model.c | 7 +++++--
 src/gnome/dialog-sx-editor.c          | 9 +++++++--
 2 files changed, 12 insertions(+), 4 deletions(-)



More information about the gnucash-changes mailing list