[Gnucash-changes] r13053 - gnucash/trunk - Need to insert splits into accounts before called xaccSplitSetBaseValue().

Derek Atkins warlord at cvs.gnucash.org
Mon Jan 30 12:17:33 EST 2006


Author: warlord
Date: 2006-01-30 12:17:33 -0500 (Mon, 30 Jan 2006)
New Revision: 13053
Trac: http://svn.gnucash.org/trac/changeset/13053

Modified:
   gnucash/trunk/ChangeLog
   gnucash/trunk/src/business/business-core/gncInvoice.c
Log:
Need to insert splits into accounts before called xaccSplitSetBaseValue().

	* src/business/business-core/gncInvoice.c:
	  Make sure to insert new splits into an account before we
	  set the Base Value..  Otherwise it will fail to set the
	  value properly.  Closer to fixing 325890, but it's still
	  not completely fixed.



Modified: gnucash/trunk/ChangeLog
===================================================================
--- gnucash/trunk/ChangeLog	2006-01-30 16:40:25 UTC (rev 13052)
+++ gnucash/trunk/ChangeLog	2006-01-30 17:17:33 UTC (rev 13053)
@@ -1,3 +1,11 @@
+2006-01-30  Derek Atkins  <derek at ihtfp.com>
+
+	* src/business/business-core/gncInvoice.c:
+	  Make sure to insert new splits into an account before we
+	  set the Base Value..  Otherwise it will fail to set the
+	  value properly.  Closer to fixing 325890, but it's still
+	  not completely fixed.
+
 2006-01-30  Joshua Sled  <jsled at asynchronous.org>
 
 	* src/gnome/glade/sched-xact.glade: Change since-last-run

Modified: gnucash/trunk/src/business/business-core/gncInvoice.c
===================================================================
--- gnucash/trunk/src/business/business-core/gncInvoice.c	2006-01-30 16:40:25 UTC (rev 13052)
+++ gnucash/trunk/src/business/business-core/gncInvoice.c	2006-01-30 17:17:33 UTC (rev 13053)
@@ -937,12 +937,16 @@
 	  xaccSplitSetMemo (split, gncEntryGetDescription (entry));
 	  xaccSplitSetAction (split, type);
 
+	  /* Need to insert this split into the account before
+	   * we set the Base Value.  Otherwise SetBaseValue complains
+	   * that we don't have an account.
+	   */
+	  xaccAccountBeginEdit (this_acc);
+	  xaccAccountInsertSplit (this_acc, split);
+	  xaccAccountCommitEdit (this_acc);
 	  xaccSplitSetBaseValue (split, (reverse ? gnc_numeric_neg (value)
 					 : value),
 				 invoice->currency);
-	  xaccAccountBeginEdit (this_acc);
-	  xaccAccountInsertSplit (this_acc, split);
-	  xaccAccountCommitEdit (this_acc);
 	  xaccTransAppendSplit (txn, split);
 	}
 
@@ -962,11 +966,11 @@
 	  /* set action? */
 	  xaccSplitSetMemo (split, gncEntryGetDescription (entry));
 	  xaccSplitSetAction (split, type);
-	  xaccSplitSetBaseValue (split, (reverse ? value : gnc_numeric_neg (value)),
-				 invoice->currency);
 	  xaccAccountBeginEdit (ccard_acct);
 	  xaccAccountInsertSplit (ccard_acct, split);
 	  xaccAccountCommitEdit (ccard_acct);
+	  xaccSplitSetBaseValue (split, (reverse ? value : gnc_numeric_neg (value)),
+				 invoice->currency);
 	  xaccTransAppendSplit (txn, split);
 	  
 	} else
@@ -998,12 +1002,12 @@
     xaccSplitSetMemo (split, memo);
     xaccSplitSetAction (split, type);
 
+    xaccAccountBeginEdit (acc_val->account);
+    xaccAccountInsertSplit (acc_val->account, split);
+    xaccAccountCommitEdit (acc_val->account);
     xaccSplitSetBaseValue (split, (reverse ? gnc_numeric_neg (acc_val->value)
 				   : acc_val->value),
 			   invoice->currency);
-    xaccAccountBeginEdit (acc_val->account);
-    xaccAccountInsertSplit (acc_val->account, split);
-    xaccAccountCommitEdit (acc_val->account);
     xaccTransAppendSplit (txn, split);
   }
 
@@ -1017,12 +1021,12 @@
     xaccSplitSetMemo (split, _("Extra to Charge Card"));
     xaccSplitSetAction (split, type);
     
+    xaccAccountBeginEdit (ccard_acct);
+    xaccAccountInsertSplit (ccard_acct, split);
+    xaccAccountCommitEdit (ccard_acct);
     xaccSplitSetBaseValue (split, (reverse ? invoice->to_charge_amount :
 				   gnc_numeric_neg(invoice->to_charge_amount)),
 			   invoice->currency);
-    xaccAccountBeginEdit (ccard_acct);
-    xaccAccountInsertSplit (ccard_acct, split);
-    xaccAccountCommitEdit (ccard_acct);
     xaccTransAppendSplit (txn, split);
 
     total = gnc_numeric_sub (total, invoice->to_charge_amount,
@@ -1037,11 +1041,11 @@
     xaccSplitSetMemo (split, memo);
     xaccSplitSetAction (split, type);
 			   
-    xaccSplitSetBaseValue (split, (reverse ? total : gnc_numeric_neg (total)),
-			   invoice->currency);
     xaccAccountBeginEdit (acc);
     xaccAccountInsertSplit (acc, split);
     xaccAccountCommitEdit (acc);
+    xaccSplitSetBaseValue (split, (reverse ? total : gnc_numeric_neg (total)),
+			   invoice->currency);
     xaccTransAppendSplit (txn, split);
 
     /* add this split to the lot */
@@ -1095,9 +1099,9 @@
     split = xaccMallocSplit (invoice->inst.book);
     xaccSplitSetMemo (split, memo2);
     xaccSplitSetAction (split, action2);
+    xaccAccountInsertSplit (acc, split);
     xaccSplitSetBaseValue (split, gnc_numeric_neg (total),
 			   invoice->currency);
-    xaccAccountInsertSplit (acc, split);
     xaccTransAppendSplit (t2, split);
     gnc_lot_add_split (lot, split);
 
@@ -1105,8 +1109,8 @@
     split = xaccMallocSplit (invoice->inst.book);
     xaccSplitSetMemo (split, memo2);
     xaccSplitSetAction (split, action2);
+    xaccAccountInsertSplit (acc, split);
     xaccSplitSetBaseValue (split, total, invoice->currency);
-    xaccAccountInsertSplit (acc, split);
     xaccTransAppendSplit (t2, split);
     gnc_lot_add_split (lot2, split);
 
@@ -1264,11 +1268,11 @@
   split = xaccMallocSplit (book);
   xaccSplitSetMemo (split, memo);
   xaccSplitSetAction (split, _("Payment"));
-  xaccSplitSetBaseValue (split, reverse ? amount :
-			 gnc_numeric_neg (amount), commodity);
   xaccAccountBeginEdit (xfer_acc);
   xaccAccountInsertSplit (xfer_acc, split);
   xaccAccountCommitEdit (xfer_acc);
+  xaccSplitSetBaseValue (split, reverse ? amount :
+			 gnc_numeric_neg (amount), commodity);
   xaccTransAppendSplit (txn, split);
 
   /* Now, find all "open" lots in the posting account for this
@@ -1326,9 +1330,9 @@
     split = xaccMallocSplit (book);
     xaccSplitSetMemo (split, memo);
     xaccSplitSetAction (split, _("Payment"));
+    xaccAccountInsertSplit (posted_acc, split);
     xaccSplitSetBaseValue (split, reverse ? gnc_numeric_neg (split_amt) :
 			   split_amt, commodity);
-    xaccAccountInsertSplit (posted_acc, split);
     xaccTransAppendSplit (txn, split);
     gnc_lot_add_split (lot, split);
 
@@ -1353,9 +1357,9 @@
     split = xaccMallocSplit (book);
     xaccSplitSetMemo (split, memo);
     xaccSplitSetAction (split, _("Pre-Payment"));
+    xaccAccountInsertSplit (posted_acc, split);
     xaccSplitSetBaseValue (split, reverse ? gnc_numeric_neg (amount) :
 			   amount, commodity);
-    xaccAccountInsertSplit (posted_acc, split);
     xaccTransAppendSplit (txn, split);
     gnc_lot_add_split (prepay_lot, split);
   }



More information about the gnucash-changes mailing list