fix handling of account commodities when closing periods

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@9476 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Linas Vepstas 2003-10-12 02:40:10 +00:00
parent d0fe8b67ed
commit 542ce3bed4
2 changed files with 21 additions and 5 deletions

View File

@ -157,6 +157,8 @@ xaccMallocAccount (QofBook *book)
Account *
xaccCloneAccountSimple(const Account *from, QofBook *book)
{
const char * ucom;
const gnc_commodity_table * comtbl;
Account *ret;
if (!from || !book) return NULL;
@ -178,7 +180,12 @@ xaccCloneAccountSimple(const Account *from, QofBook *book)
ret->kvp_data = kvp_frame_copy(from->kvp_data);
ret->commodity = from->commodity;
/* The new book should contain a commodity that matches
* the one in the old book. Find it, use it. */
ucom = gnc_commodity_get_unique_name (from->commodity);
comtbl = gnc_commodity_table_get_table (book);
ret->commodity = gnc_commodity_table_lookup_unique (comtbl, ucom);
ret->commodity_scu = from->commodity_scu;
ret->non_standard_scu = from->non_standard_scu;
ret->core_dirty = TRUE;
@ -212,7 +219,12 @@ xaccCloneAccount (const Account *from, QofBook *book,
ret->kvp_data = kvp_frame_copy(from->kvp_data);
ret->commodity = from->commodity;
/* The new book should contain a commodity that matches
* the one in the old book. Find it, use it. */
ucom = gnc_commodity_get_unique_name (from->commodity);
comtbl = gnc_commodity_table_get_table (book);
ret->commodity = gnc_commodity_table_lookup_unique (comtbl, ucom);
ret->commodity_scu = from->commodity_scu;
ret->non_standard_scu = from->non_standard_scu;
ret->core_dirty = TRUE;

View File

@ -118,9 +118,13 @@ Account * xaccCloneAccount (const Account *from, QofBook *book,
/** The xaccCloneAccountSimple() routine makes a simple copy of the
* indicated account, placing it in the indicated book. It copies
* the account type, name, description, and the kvp values;
* it does not copy splits/transactions. Note also that it
* does NOT use the 'gemini' kvp value to indicate where it
* was copied from.*/
* it does not copy splits/transactions. The book should have
* a commodity table in it that has commodities with the same
* unique name as the ones being copied in the account (the
* commodities in the clone will be those from the book).
* Note that this routines does *NOT* use the 'gemini' kvp value
* to indicate where it was copied from.
*/
Account * xaccCloneAccountSimple (const Account *from, QofBook *book);
/** The xaccAccountBeginEdit() subroutine is the first phase of