[Gnucash-changes] r13068 - gnucash/trunk - Need to put the new split into the txn as well as the acct

Derek Atkins warlord at cvs.gnucash.org
Wed Feb 1 16:23:55 EST 2006


Author: warlord
Date: 2006-02-01 16:23:54 -0500 (Wed, 01 Feb 2006)
New Revision: 13068
Trac: http://svn.gnucash.org/trac/changeset/13068

Modified:
   gnucash/trunk/ChangeLog
   gnucash/trunk/src/business/business-core/gncInvoice.c
Log:
	  Need to put the new split into the txn as well as the acct
	  before we call xaccSplitSetBaseValue().  Fixes #325890.



Modified: gnucash/trunk/ChangeLog
===================================================================
--- gnucash/trunk/ChangeLog	2006-02-01 20:33:36 UTC (rev 13067)
+++ gnucash/trunk/ChangeLog	2006-02-01 21:23:54 UTC (rev 13068)
@@ -1,3 +1,9 @@
+2006-02-01  Derek Atkins  <derek at ihtfp.com>
+
+	* src/business/business-core/gncInvoice.c:
+	  Need to put the new split into the txn as well as the acct
+	  before we call xaccSplitSetBaseValue().  Fixes #325890.
+
 2006-01-31  Derek Atkins  <derek at ihtfp.com>
 
 	* configure.in: include gmodule in GLIB_LIBS

Modified: gnucash/trunk/src/business/business-core/gncInvoice.c
===================================================================
--- gnucash/trunk/src/business/business-core/gncInvoice.c	2006-02-01 20:33:36 UTC (rev 13067)
+++ gnucash/trunk/src/business/business-core/gncInvoice.c	2006-02-01 21:23:54 UTC (rev 13068)
@@ -937,17 +937,17 @@
 	  xaccSplitSetMemo (split, gncEntryGetDescription (entry));
 	  xaccSplitSetAction (split, type);
 
-	  /* Need to insert this split into the account before
+	  /* Need to insert this split into the account AND txn before
 	   * we set the Base Value.  Otherwise SetBaseValue complains
-	   * that we don't have an account.
+	   * that we don't have an account and fails to set the value.
 	   */
 	  xaccAccountBeginEdit (this_acc);
 	  xaccAccountInsertSplit (this_acc, split);
 	  xaccAccountCommitEdit (this_acc);
+	  xaccTransAppendSplit (txn, split);
 	  xaccSplitSetBaseValue (split, (reverse ? gnc_numeric_neg (value)
 					 : value),
 				 invoice->currency);
-	  xaccTransAppendSplit (txn, split);
 	}
 
 	/* If there is a credit-card account, and this is a CCard
@@ -969,9 +969,9 @@
 	  xaccAccountBeginEdit (ccard_acct);
 	  xaccAccountInsertSplit (ccard_acct, split);
 	  xaccAccountCommitEdit (ccard_acct);
+	  xaccTransAppendSplit (txn, split);
 	  xaccSplitSetBaseValue (split, (reverse ? value : gnc_numeric_neg (value)),
 				 invoice->currency);
-	  xaccTransAppendSplit (txn, split);
 	  
 	} else
 	  total = gnc_numeric_add (total, value, GNC_DENOM_AUTO, GNC_DENOM_LCD);
@@ -1005,10 +1005,10 @@
     xaccAccountBeginEdit (acc_val->account);
     xaccAccountInsertSplit (acc_val->account, split);
     xaccAccountCommitEdit (acc_val->account);
+    xaccTransAppendSplit (txn, split);
     xaccSplitSetBaseValue (split, (reverse ? gnc_numeric_neg (acc_val->value)
 				   : acc_val->value),
 			   invoice->currency);
-    xaccTransAppendSplit (txn, split);
   }
 
   /* If there is a ccard account, we may have an additional "to_card" payment.
@@ -1024,10 +1024,10 @@
     xaccAccountBeginEdit (ccard_acct);
     xaccAccountInsertSplit (ccard_acct, split);
     xaccAccountCommitEdit (ccard_acct);
+    xaccTransAppendSplit (txn, split);
     xaccSplitSetBaseValue (split, (reverse ? invoice->to_charge_amount :
 				   gnc_numeric_neg(invoice->to_charge_amount)),
 			   invoice->currency);
-    xaccTransAppendSplit (txn, split);
 
     total = gnc_numeric_sub (total, invoice->to_charge_amount,
 			     GNC_DENOM_AUTO, GNC_DENOM_LCD);
@@ -1044,9 +1044,9 @@
     xaccAccountBeginEdit (acc);
     xaccAccountInsertSplit (acc, split);
     xaccAccountCommitEdit (acc);
+    xaccTransAppendSplit (txn, split);
     xaccSplitSetBaseValue (split, (reverse ? total : gnc_numeric_neg (total)),
 			   invoice->currency);
-    xaccTransAppendSplit (txn, split);
 
     /* add this split to the lot */
     gnc_lot_add_split (lot, split);
@@ -1100,9 +1100,9 @@
     xaccSplitSetMemo (split, memo2);
     xaccSplitSetAction (split, action2);
     xaccAccountInsertSplit (acc, split);
+    xaccTransAppendSplit (t2, split);
     xaccSplitSetBaseValue (split, gnc_numeric_neg (total),
 			   invoice->currency);
-    xaccTransAppendSplit (t2, split);
     gnc_lot_add_split (lot, split);
 
     /* And apply the pre-payment to a new lot */
@@ -1110,8 +1110,8 @@
     xaccSplitSetMemo (split, memo2);
     xaccSplitSetAction (split, action2);
     xaccAccountInsertSplit (acc, split);
+    xaccTransAppendSplit (t2, split);
     xaccSplitSetBaseValue (split, total, invoice->currency);
-    xaccTransAppendSplit (t2, split);
     gnc_lot_add_split (lot2, split);
 
     xaccTransCommitEdit (t2);
@@ -1271,9 +1271,9 @@
   xaccAccountBeginEdit (xfer_acc);
   xaccAccountInsertSplit (xfer_acc, split);
   xaccAccountCommitEdit (xfer_acc);
+  xaccTransAppendSplit (txn, split);
   xaccSplitSetBaseValue (split, reverse ? amount :
 			 gnc_numeric_neg (amount), commodity);
-  xaccTransAppendSplit (txn, split);
 
   /* Now, find all "open" lots in the posting account for this
    * company and apply the payment on a FIFO basis.  Create
@@ -1331,9 +1331,9 @@
     xaccSplitSetMemo (split, memo);
     xaccSplitSetAction (split, _("Payment"));
     xaccAccountInsertSplit (posted_acc, split);
+    xaccTransAppendSplit (txn, split);
     xaccSplitSetBaseValue (split, reverse ? gnc_numeric_neg (split_amt) :
 			   split_amt, commodity);
-    xaccTransAppendSplit (txn, split);
     gnc_lot_add_split (lot, split);
 
     /* Now send an event for the invoice so it gets updated as paid */
@@ -1358,9 +1358,9 @@
     xaccSplitSetMemo (split, memo);
     xaccSplitSetAction (split, _("Pre-Payment"));
     xaccAccountInsertSplit (posted_acc, split);
+    xaccTransAppendSplit (txn, split);
     xaccSplitSetBaseValue (split, reverse ? gnc_numeric_neg (amount) :
 			   amount, commodity);
-    xaccTransAppendSplit (txn, split);
     gnc_lot_add_split (prepay_lot, split);
   }
 



More information about the gnucash-changes mailing list