From 4e5eb3ce11835c8517696ed0bdcfcb73038a1c88 Mon Sep 17 00:00:00 2001 From: Linas Vepstas Date: Fri, 18 Sep 1998 01:10:39 +0000 Subject: [PATCH] check currency before blithly allowing transfers git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@1182 57a11ea4-9604-0410-9ed3-97b8803252fd --- src/engine/Account.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/engine/Account.c b/src/engine/Account.c index 62072da3d3..c1747109af 100644 --- a/src/engine/Account.c +++ b/src/engine/Account.c @@ -223,6 +223,19 @@ xaccAccountInsertSplit ( Account *acc, Split *split ) if (!split) return; CHECK (acc); + /* if this split belongs to another account, make sure that + * the moving it is allowed by the currency denominations of + * the old and new accounts + */ + if (split->acc) { + if (acc->currency) { + if (!(split->acc->currency)) return; + if (strcmp (acc->currency, split->acc->currency)) return; + } else { + if (split->acc->currency) return; + } + } + /* mark the account as having changed, and * the account group as requiring a save */ acc -> changed = TRUE; @@ -603,10 +616,9 @@ xaccMoveFarEnd (Split *split, Account *new_acc) return; } - /* remove the partner split from the old account */ + /* move the partner split from the old account to the new */ acc = (Account *) (partner_split->acc); if (acc != new_acc) { - xaccAccountRemoveSplit (acc, partner_split); xaccAccountInsertSplit (new_acc, partner_split); } }