summaryrefslogtreecommitdiff
path: root/src/generate.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2010-06-02 06:12:14 -0400
committerJohn Wiegley <johnw@newartisans.com>2010-06-02 06:13:40 -0400
commit90d5ef83b60c8ba6d4b8971d82e3d2ec4bf1d0b6 (patch)
tree2e3876b24c95080db448e8c312e56114321c8248 /src/generate.cc
parentf68b4d0f0fc9232a60e384de72743643ace0ceb7 (diff)
downloadfork-ledger-90d5ef83b60c8ba6d4b8971d82e3d2ec4bf1d0b6.tar.gz
fork-ledger-90d5ef83b60c8ba6d4b8971d82e3d2ec4bf1d0b6.tar.bz2
fork-ledger-90d5ef83b60c8ba6d4b8971d82e3d2ec4bf1d0b6.zip
Don't gen posting with same cost, amount commodity
Diffstat (limited to 'src/generate.cc')
-rw-r--r--src/generate.cc17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/generate.cc b/src/generate.cc
index 9b4c2ee7..8ea1ab45 100644
--- a/src/generate.cc
+++ b/src/generate.cc
@@ -163,7 +163,8 @@ bool generate_posts_iterator::generate_account(std::ostream& out,
return must_balance;
}
-void generate_posts_iterator::generate_commodity(std::ostream& out)
+void generate_posts_iterator::generate_commodity(std::ostream& out,
+ const string& exclude)
{
string comm;
do {
@@ -171,8 +172,8 @@ void generate_posts_iterator::generate_commodity(std::ostream& out)
generate_string(buf, six_gen(), true);
comm = buf.str();
}
- while (comm == "h" || comm == "m" || comm == "s" || comm == "and" ||
- comm == "any" || comm == "all" || comm == "div" ||
+ while (comm == exclude || comm == "h" || comm == "m" || comm == "s" ||
+ comm == "and" || comm == "any" || comm == "all" || comm == "div" ||
comm == "false" || comm == "or" || comm == "not" ||
comm == "true" || comm == "if" || comm == "else");
@@ -181,12 +182,13 @@ void generate_posts_iterator::generate_commodity(std::ostream& out)
string generate_posts_iterator::generate_amount(std::ostream& out,
value_t not_this_amount,
- bool no_negative)
+ bool no_negative,
+ const string& exclude)
{
std::ostringstream buf;
if (truth_gen()) { // commodity goes in front
- generate_commodity(buf);
+ generate_commodity(buf, exclude);
if (truth_gen())
buf << ' ';
if (no_negative || truth_gen())
@@ -200,7 +202,7 @@ string generate_posts_iterator::generate_amount(std::ostream& out,
buf << neg_number_gen();
if (truth_gen())
buf << ' ';
- generate_commodity(buf);
+ generate_commodity(buf, exclude);
}
// Possibly generate an annotized commodity, but make it rarer
@@ -259,7 +261,8 @@ void generate_posts_iterator::generate_cost(std::ostream& out, value_t amount)
else
buf << " @@ ";
- if (! generate_amount(buf, amount, true).empty())
+ if (! generate_amount(buf, amount, true,
+ amount.as_amount().commodity().symbol()).empty())
out << buf.str();
}