summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/xact.cc23
-rw-r--r--test/regress/5D92A5EB.test34
2 files changed, 55 insertions, 2 deletions
diff --git a/src/xact.cc b/src/xact.cc
index 4e8e56fa..f514776f 100644
--- a/src/xact.cc
+++ b/src/xact.cc
@@ -111,6 +111,14 @@ value_t xact_base_t::magnitude() const
return halfbal;
}
+namespace {
+ inline bool account_ends_with_special_char(const string& name) {
+ string::size_type len(name.length());
+ return (std::isdigit(name[len - 1]) || name[len - 1] == ')' ||
+ name[len - 1] == '}' || name[len - 1] == ']');
+ }
+}
+
bool xact_base_t::finalize()
{
// Scan through and compute the total balance for the xact. This is used
@@ -136,8 +144,19 @@ bool xact_base_t::finalize()
p.rounded().reduced() : p.reduced());
}
else if (null_post) {
- throw_(std::logic_error,
- _("Only one posting with null amount allowed per transaction"));
+ bool post_account_bad =
+ account_ends_with_special_char(post->account->fullname());
+ bool null_post_account_bad =
+ account_ends_with_special_char(null_post->account->fullname());
+
+ if (post_account_bad || null_post_account_bad)
+ throw_(std::logic_error,
+ _("Posting with null amount's account may be mispelled:\n \"%1\"")
+ << (post_account_bad ? post->account->fullname() :
+ null_post->account->fullname()));
+ else
+ throw_(std::logic_error,
+ _("Only one posting with null amount allowed per transaction"));
}
else {
null_post = post;
diff --git a/test/regress/5D92A5EB.test b/test/regress/5D92A5EB.test
new file mode 100644
index 00000000..1d3a06bb
--- /dev/null
+++ b/test/regress/5D92A5EB.test
@@ -0,0 +1,34 @@
+~ Monthly from 2010/7/1
+ Expenses:Auto:Gas $100.00
+ Expenses:Auto:Insurance $100.00
+ Expenses:Childcare $100.00
+ Expenses:Entertainment:Blizzard $100.00
+ Expenses:Entertainment:Netflix $100.00
+ Expenses:Groceries $100.00
+ Expenses:Utilities:Electric $100.00
+ Expenses:Utilities:Water $100.00
+ Expenses:Utilities:Sewage $100.00
+ Liabilities:Education:ULL $100.00
+ Liabilities:Mortgage $100.00
+ Assets:Bank:Checking
+
+test -J reg checking -> 1
+__ERROR__
+While parsing file "$sourcepath/test/regress/5D92A5EB.test", line 13:
+While parsing periodic transaction:
+> ~ Monthly from 2010/7/1
+> Expenses:Auto:Gas $100.00
+> Expenses:Auto:Insurance $100.00
+> Expenses:Childcare $100.00
+> Expenses:Entertainment:Blizzard $100.00
+> Expenses:Entertainment:Netflix $100.00
+> Expenses:Groceries $100.00
+> Expenses:Utilities:Electric $100.00
+> Expenses:Utilities:Water $100.00
+> Expenses:Utilities:Sewage $100.00
+> Liabilities:Education:ULL $100.00
+> Liabilities:Mortgage $100.00
+> Assets:Bank:Checking
+Error: Posting with null amount's account may be mispelled:
+ "Expenses:Entertainment:Blizzard $100.00"
+end test