mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Christian Stimming's patch for editing currency accounts.
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@2797 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
4634680378
commit
28defdc0f2
@ -2596,11 +2596,11 @@ xaccSRSaveChangedCells (SplitRegister *reg, Transaction *trans, Split *split)
|
||||
const char *security = NULL;
|
||||
|
||||
currency = xaccAccountGetCurrency(new_acc);
|
||||
currency = xaccTransIsCommonCurrency(trans, currency);
|
||||
currency = xaccTransIsCommonExclSCurrency(trans, currency, split);
|
||||
|
||||
if (currency == NULL) {
|
||||
security = xaccAccountGetSecurity(new_acc);
|
||||
security = xaccTransIsCommonCurrency(trans, security);
|
||||
security = xaccTransIsCommonExclSCurrency(trans, security, split);
|
||||
}
|
||||
|
||||
if ((currency != NULL) || (security != NULL)) {
|
||||
@ -2669,11 +2669,11 @@ xaccSRSaveChangedCells (SplitRegister *reg, Transaction *trans, Split *split)
|
||||
const char *security = NULL;
|
||||
|
||||
currency = xaccAccountGetCurrency(new_acc);
|
||||
currency = xaccTransIsCommonCurrency(trans, currency);
|
||||
currency = xaccTransIsCommonExclSCurrency(trans, currency, split);
|
||||
|
||||
if (currency == NULL) {
|
||||
security = xaccAccountGetSecurity(new_acc);
|
||||
security = xaccTransIsCommonCurrency(trans, security);
|
||||
security = xaccTransIsCommonExclSCurrency(trans, security, split);
|
||||
}
|
||||
|
||||
if ((currency != NULL) || (security != NULL)) {
|
||||
|
@ -846,7 +846,9 @@ xaccIsCommonCurrency(const char *currency_1, const char *security_1,
|
||||
}
|
||||
|
||||
static const char *
|
||||
FindCommonCurrency (Split **slist, const char * ra, const char * rb)
|
||||
FindCommonExclSCurrency (Split **slist,
|
||||
const char * ra, const char * rb,
|
||||
Split *excl_split)
|
||||
{
|
||||
Split *s;
|
||||
int i = 0;
|
||||
@ -855,10 +857,17 @@ FindCommonCurrency (Split **slist, const char * ra, const char * rb)
|
||||
|
||||
if (rb && ('\0' == rb[0])) rb = NULL;
|
||||
|
||||
i=0; s = slist[0];
|
||||
i = 0;
|
||||
s = slist[0];
|
||||
|
||||
/* If s is to be excluded, go ahead in the list until one split is
|
||||
not excluded or is NULL. */
|
||||
while (s && (s == excl_split))
|
||||
{ i++; s = slist[i]; }
|
||||
|
||||
while (s) {
|
||||
char *sa, *sb;
|
||||
|
||||
|
||||
/* Novice/casual users may not want or use the double entry
|
||||
* features of this engine. Because of this, there
|
||||
* may be the occasional split without a parent account.
|
||||
@ -901,12 +910,28 @@ FindCommonCurrency (Split **slist, const char * ra, const char * rb)
|
||||
}
|
||||
|
||||
if ((!ra) && (!rb)) return NULL;
|
||||
i++; s = slist[i];
|
||||
|
||||
i++;
|
||||
s = slist[i];
|
||||
|
||||
/* If s is to be excluded, go ahead in the list until one split is
|
||||
not excluded or is NULL. */
|
||||
while (s && (s == excl_split))
|
||||
{ i++; s = slist[i]; }
|
||||
}
|
||||
|
||||
return (ra);
|
||||
}
|
||||
|
||||
/* This is the wrapper for those calls (i.e. the older ones) which
|
||||
* don't exclude one split from the splitlist when looking for a
|
||||
* common currency.
|
||||
*/
|
||||
static const char *
|
||||
FindCommonCurrency (Split **slist, const char * ra, const char * rb)
|
||||
{
|
||||
return FindCommonExclSCurrency(slist, ra, rb, NULL);
|
||||
}
|
||||
|
||||
const char *
|
||||
xaccTransFindCommonCurrency (Transaction *trans)
|
||||
@ -929,6 +954,13 @@ xaccTransIsCommonCurrency (Transaction *trans, const char * ra)
|
||||
return FindCommonCurrency (trans->splits, ra, NULL);
|
||||
}
|
||||
|
||||
const char *
|
||||
xaccTransIsCommonExclSCurrency (Transaction *trans,
|
||||
const char * ra, Split *excl_split)
|
||||
{
|
||||
return FindCommonExclSCurrency (trans->splits, ra, NULL, excl_split);
|
||||
}
|
||||
|
||||
/********************************************************************\
|
||||
\********************************************************************/
|
||||
|
||||
|
@ -295,6 +295,20 @@ const char * xaccTransFindCommonCurrency (Transaction *trans);
|
||||
const char * xaccTransIsCommonCurrency (Transaction *trans,
|
||||
const char * currency);
|
||||
|
||||
/* The xaccTransIsCommonExclSCurrency () method compares the input
|
||||
* string to the currency/security denominations of all splits in
|
||||
* the transaction except the one given as parameter, and returns
|
||||
* the input string if it is common with all splits except the one
|
||||
* given, otherwise, it returns NULL.
|
||||
*
|
||||
* This is useful when changing one split such that the old entry in
|
||||
* that split is of no relevance when determining whether the new entry
|
||||
* has a common currency with the other splits.
|
||||
*/
|
||||
const char * xaccTransIsCommonExclSCurrency (Transaction *trans,
|
||||
const char * currency,
|
||||
Split *excl_split);
|
||||
|
||||
/* The xaccTransGetImbalance() method returns the total value of the
|
||||
* transaction. In a pure double-entry system, this imbalance
|
||||
* should be exactly zero, and if it is not, something is broken.
|
||||
|
Loading…
Reference in New Issue
Block a user